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.

I'm trying to load the jQuery UI library into a WordPress plugin using this enqueue statement:

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

The jQuery library loads fine, but the ui-core is MIA. The only way I can get ui-core functions to fire is to load the library with a static include like this:

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.15/jquery-ui.min.js"></script>

What am I missing?

share|improve this question
add comment

1 Answer 1

up vote 2 down vote accepted

jquery is enqueued by default on admin side. So, it may not be loading due to your wp_enqueue_script statement. Are you using wp_enqueue_script inside some action hook? Because you have to. I use it like this:

add_action( 'admin_enqueue_scripts-options_page-{page}', 'myplugin_admin_scripts' );
function myplugin_admin_scripts() {
    wp_enqueue_script('jquery');
    wp_enqueue_script('jquery-ui-core');
} 
share|improve this answer
2  
Don't enqueue scripts nakedly in the Admin interface. Use a more specific page hook, i.e. the hook specific to your Plugin's (or your Theme's) settings page. –  Chip Bennett Aug 12 '11 at 19:22
    
Additionally, you shouldn't even need to call jQuery, i believe(and someone correct me if you know otherwise) that jQuery is a dependancy for jQuery UI - so just calling UI on it's own should be sufficient. –  t31os Aug 14 '11 at 12:19
add comment

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.