Jquery Accordion Close then Open
- by Jon
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?