• I’m having an issue with jquery plugins. I can verify that the .js files are being included properly, but I’m getting an undefined method error.

    Here is my header:

    wp_enqueue_script('jquery');
    wp_enqueue_script('orbit', get_bloginfo('template_url') . '/public/assets/orbit/jquery.orbit.min.js', array('jquery'));
    get_header();

    and I call the orbit slider:

    <script>
    jQuery(document).ready(function(){
        jQuery('#slider').orbit();
    });
    </script>

    I know the code in the orbit.js file is being executed because I put alerts in it and saw them.

    If I run the minified orbit.js code in the browser console and then call orbit on my slider element, it works.

    I created a slideshow with orbit outside of wordpress and had no issues.

    Thanks for any help!

Viewing 6 replies - 1 through 6 (of 6 total)
  • You shouldn’t be enqueueing scripts in header.php! This should done via a function in your theme’s functions.php file and then hooked into an appropriate action. See http://codex.wordpress.org/Function_Reference/wp_enqueue_script

    Thread Starter JohnColvin

    (@johncolvin)

    Thanks for the quick response.

    The enqueues weren’t in header.php, they were in page.php. I had them in functions.php earlier and had the same problem.

    I just moved them back there and hooked to the init action. I’m having the same problem.

    Try something like:

    function my_script_calls () {
    	wp_enqueue_script('orbit', get_bloginfo('template_url') . '/public/assets/orbit/jquery.orbit.min.js', array('jquery'));
    }
    add_action('template_redirect', 'my_script_calls');

    Also check the path to your script. Is it really in http://example.com/wpcontent/themes/theme_name/public/assets/orbit/ ?

    Thread Starter JohnColvin

    (@johncolvin)

    I tried the code you provided. I’m still having the issue.

    The path is correct. The script is in the list of resources loaded on the page.

    I’m totally stumped.

    Thread Starter JohnColvin

    (@johncolvin)

    I did a fresh install and I’m having the same issue.

    I have multi-user enabled. Could that be involved with this issue?

    Thread Starter JohnColvin

    (@johncolvin)

    I can confirm that this is only an issue for wordpress MU. When I disable MU, the slider works just fine.

    I can’t find any posts about people having issues with queuing scripts in MU, though.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Javascript undefined method’ is closed to new replies.