Adding jQuery UI selectmenu() to Drupal form I'm trying to add a styling to the select form elements in my Drupal form using jQuery UI. I'm using Drupal 7 so the usual way to add jQuery UI would be something like this:

 drupal_add_library('system', 'ui.accordion');
 drupal_add_js('jQuery(document).ready(function(){jQuery("#accordion").accordion();});', 'inline');


However, when I try to add an effect that isn't bundled with Drupal 7 core, like this one, that approach doesn't work. Has anyone come across this problem before, and if so, is there a "standard" Drupal way of solving this?
I think the 'Drupal' way would be to implement hook_library() to add the new element to the system:

function MYMODULE_library() {
  $libraries['ui.selectmenu'] = array(
    'title' =&gt; 'jQuery UI: Selectmenu', 
    'website' =&gt; 'http://filamentgroup.com/lab/jquery_ui_selectmenu_an_aria_accessible_plugin_for_styling_a_html_select/', 
    'version' =&gt; '1.8.7', 
    'js' =&gt; array(
      drupal_get_path('module', 'MYMODULE') . '/jquery.ui.selectmenu.min.js' =&gt; array(),
    ), 
    'dependencies' =&gt; array(
      array('system', 'ui.widget')
    ),
  );

  return $libraries;
}


And then add it to your pages using drupal_add_library():

drupal_add_library('MYMODULE', 'ui.selectmenu');


Doing it this way ensures that all the necessary core UI files are included in the page automatically, and allows you to add the widget with a single line of code any time you want to.