wp_enqueue_script with Jquery UI and Tabs (5 posts)

  1. arpowers
    Posted 5 years ago #

    HI everyone,

    I'm having a really hard time getting 'wp_enqueue_script' to load correctly and work in the admin.

    Here is my code:

    function load_scripts(){
    	wp_enqueue_script( 'jquery' );
    	wp_enqueue_script( 'jquery-ui-core' );
    	wp_enqueue_script( 'jquery-ui-tabs' );
    	echo '<script type="text/javascript">
    		jQuery(document).ready(function($) {
    	echo '
    	<style type="text/css">
    	.ui-tabs .ui-tabs-hide {
    	     display: none;
    add_action( 'admin_head', 'load_scripts' );

    its not loading in the scripts and it's returning an: "jQuery("#tabs").tabs is not a function" error in FireBug.

    Please help..

  2. Drew Baker
    Posted 5 years ago #

    Hey did you figure this out? If so how'd you do it?

  3. sojournings
    Posted 5 years ago #

    hey, I figured this one out..
    when you are using the "add_action" to load the scripts make sure you use the 'wp_print_scripts' hook. Hope this helps.

  4. smakdaddy
    Posted 5 years ago #

    hey guys. having this problem myself, very frustrating.

    jquery-ui simply won't load using the wp_enqueue_script function.

    the only way i can get this to function (albeit, without jqueryui css) is this;

    function load_custom_scripts() {
    	wp_register_script('my-jquery-ui', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/jquery-ui.js');
    	wp_enqueue_script( 'my-jquery-ui' );
    add_action('admin_init', 'load_custom_scripts');

    this should work but doesn't.

    wp_enqueue_script( 'jquery-ui-core' );

    I've tried @designerfoo'sn suggestion above but that doesn't work.

    any ideas?

  5. hpv24sabine
    Posted 5 years ago #

    having the same Problem yesterday when I try to load the Scripts in a Theme Header.
    Loading the Scripts by this way for Admin Functions works fine.

    Now I have a Solution for the Frontend:

    wp_enqueue_script('theme_js', get_template_directory_uri().'/js/theme.js', array('jquery', 'jquery-ui-tabs'));

    The third parameter ($deps) is crucial.
    After this call the Scripts jquery.js, ui.core.js and ui.tags.js were loaded in the Theme Header. (Tested in WP 3.0)

    From Doku:

    $deps (array) (optional) Array of handles of any script that this script depends on; scripts that must be loaded before this script. false if there are no dependencies. This parameter is only required when WordPress does not already know about this script.

    Hope it will help you to.

    P.S.: Sorry for my bad english ;-)

Topic Closed

This topic has been closed to new replies.

About this Topic