Jquery Accordion Close then Open

Posted by Jon on Stack Overflow See other posts from Stack Overflow or by Jon
Published on 2008-12-19T21:45:11Z Indexed on 2010/04/01 3:43 UTC
Read the original article Hit count: 350

Filed under:
|
|

Hi Everyone,

I've set up a number of accordions on a page using the jquery accordion plugin so I can implement expand all and collapse all functionality.

Each ID element is it's own accordion and the code below works to close them all no matter which ones are already open:

$("#contact, #address, #email, #sales, #equipment, #notes, #marketingdata")
    .accordion("activate", -1)
;

My problem is with the expand all. When I have them all expand with this code:

$("#contact, #address, #email, #sales, #equipment, #notes, #marketingdata")
    .accordion("activate", 0)
;

Some will contract and some will expand based on whether or not they are previously open.

My idea to correct this was to collapse them all and then expand them all when the expand all was clicked. This code however won't execute properly:

$("#contact, #address, #email, #sales, #equipment, #notes, #marketingdata")
    .accordion("activate", -1)
;
$("#contact, #address, #email, #sales, #equipment, #notes, #marketingdata")
    .accordion("activate", 0)
;

It will only hit the second command and not close them all first. Any suggestions?

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about accordion