Glenn De Winter Glenn De Winter - 3 years ago 154
HTML Question

jquery accordion activate does not work

I have a

accordion
like this

<div id="accordion">
<h3 id="idname1">text</h3>
<div>
Text TEXT text
</div>
<h3 id="idname2">text</h3>
<div>
Text TEXT text
</div>
<h3 id="idname3">text</h3>
<div>
Text TEXT text
</div>
</div>


Now i want the people to click a link (on the top of the page) and then that panel will open
en people will see it now every time i call my function

$('.myclass').click(function() {
// this is to open the right pannel
var getal = $(this).attr('id');
alert(getal); // i get the right name

$("#accordion").accordion('activate', 1);
});


my console gives me this error


Error: no such method 'activate' for accordion widget instance


i do not know what the problem is i have tried many different things but none worked.

Ian Ian
Answer Source

I think you are looking to open an accordion pane programmatically. If so, you want something like this:

$("#accordion").accordion("option", "active", 1);

(assuming you're using the jQuery UI library)

http://api.jqueryui.com/accordion/#option-active

Note that this opens the second accordion pane, since the options accepts a 0-based integer. (0 is first, 1 is second, etc.). So just make sure you are passing the correct integer to the method call :)

The reason your code won't work is because the jQuery UI team just removed the activate method in v1.10 and specifically recommend using what I provided: http://jqueryui.com/upgrade-guide/1.10/#removed-activate-method-use-active-option

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download