0
votes

So I've gotten two different Jquery plugins integrated into my Wordpress theme, but for some reason, when trying to use JQuery's built in accordion feature I've been getting an "undefined is not a function - anonymous function" error in the chrome console. Here is my functions.php code for the registering the jquery script:

function issue_accordion() {
wp_enqueue_script ( 'jquery' );
    wp_register_script ('jquery', get_template_directory_uri(). '/js/jquery.js' );
wp_enqueue_script( 'jqueryui' );
    wp_register_script('accordion', get_template_directory_uri(). '/js/jquery-ui.min.js');
wp_enqueue_script( 'accordion');
    wp_register_style('accordioncss', get_template_directory_uri(). '/jquery-ui.css');
    wp_register_style('accordioncss', get_template_directory_uri(). '/jquery-ui.theme.css');
    wp_register_style('accordioncss', get_template_directory_uri(). '/jquery-ui.structure.css');
    wp_enqueue_style('accordioncss');
}

add_action('wp_enqueue_scripts', 'issue_accordion');

Then this is me calling the script in the .php file:

 <script type="text/javascript">
      jQuery('#accordion').accordion();
</script>

A link to the actual page is here:

http://www.azletconsulting.com/?page_id=13

I can't figure out what the issue would be since the api documentation says the function is .accordion() and I'm properly implementing the no-conflict jquery wordpress method in the same manner as I did with the other two jquery scripts I'm using on the site.

1
jQuery doesn't have a built-in accordion function. jQuery UI does. - Samutz
So I got the Accordion function to work, but now it won't allow me to open or close any tabs. azletconsulting.com/?page_id=13 - Baroti

1 Answers

0
votes

In your HTML, you're calling jQuery('#accordion').accordion(); before the plugin has been instantiated. This is what's throwing the undefined error.