Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Using Wordpress 3.4.2, the wp_enqueue_script documentation seems to indicate that jQuery UI libraries can be loaded simply by referencing their handles. I have the following code with no prior wp_register_script():

wp_enqueue_script('jquery');
wp_enqueue_script('jquery-ui-core');

The enqueue for 'jquery' works fine, but the enqueue for 'jquery-ui-core' isn't working.

I realize that I can register and load script explicitly using Google CDN (or make explicit references to library elements in Wordpress install) ... but again documentation makes me think I shouldn't have to do this w/ Wordpress current version.

Anyone know why this doesn't work?

share|improve this question
2  
The handle jquery-ui-core does not reference the whole core incl. all core plugins, but just the base. Other than that, the above should work and the syntax is correct. –  Johannes Pille Nov 25 '12 at 15:06
3  
What isn't working? Does wp_enqueue_script( 'jquery-ui-core' ) not cause any scripts to be enqueued? Or are you missing certain UI libraries? Or something else? What do you expect to happen, but isn't happening? Or what is happening unexpectedly or differently from what you expected to happen? –  Chip Bennett Nov 25 '12 at 15:11
    
I'm expecting to get jquery-ui-core loaded via a <script src= ...> reference to the .js that Wordpress would add in page as a result of the wp_enqueue_script() call. This is happening for jquery (which I'm including first) and it's happening for other libraries, just not the jquery ui libraries when I call w/ the handle (btw if I make explicit reference to Google CDN then everything works fine). –  jalexander Nov 25 '12 at 16:34
    
What all scripts actually load? Can we see a live link to the rendered output? –  Chip Bennett Nov 25 '12 at 18:07

2 Answers 2

I guess you have to really read the Codex about wp_enqueue_script() again and then dig into jQuery a little bit more. jQuery UI is a dependency of jQuery (which means it depends on having jQuery loaded). So you need to load jQuery first, before loading jQuery UI (or jQuery UI Mobile).

Edit as per @ChipBennet and @MannyFleurmond comments below:

  1. There's no need to add array( 'jquery' ) as $dependency argument for jquery-ui-core, as Chip shows us in this core reference
  2. As Manny stated, you need to add every effect/plugin by itself, like for e.g. 'jquery-effects-fold', 'jquery-ui-resizable' or 'jquery-effects-explode'.
  3. The example is right, but missing the (possibly) needed plugins

    wp_enqueue_script( 'jquery' );
    wp_enqueue_script( 'jquery-ui-core' );
    
share|improve this answer
3  
Actually, doesn't core register jquery as a dependency of jquery-ui-core? So, calling wp_enqueue_script( 'jquery-ui-core' ) will automatically enqueue jquery? –  Chip Bennett Nov 25 '12 at 16:18
    
@ChipBennett As it's your idea, you now have to prove that fact :D –  kaiser Nov 25 '12 at 16:21
    
Refer to \wp-includes\script-loader.php, line 125. –  Chip Bennett Nov 25 '12 at 18:06
1  
Don't forget that you'll also need to load any individual jQuery UI plugins that you need, as shown here: codex.wordpress.org/Function_Reference/… –  Manny Fleurmond Nov 25 '12 at 18:38
    
Ok. Edited the answer to reflect both of your comments. @Chip owe you a beer I guess ;) –  kaiser Nov 25 '12 at 20:15

Loading jquery-ui just loads the core of the UI plugins. If you want to load individual plugins, you'll have to load the separately:

wp_enqueue_script('jquery-ui-sortable'); //load sortable
wp_enqueue_script('jquery-ui-tabs'); //load tabs

A complete list of what you can load is here

share|improve this answer
    
Indeed as documentation states: jquery-ui-core (Att.: This is not the whole core incl. all core plugins. Just the base core.). –  Didier Ghys Nov 25 '12 at 21:43

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.