Log in

View Full Version : Persist state remembered between two separate accordion menus



due23
02-06-2009, 11:15 PM
1) Script Title: Accordion Menu script

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex17/ddaccordionmenu.htm

3) Describe problem: I have a set of pages with accordion menu 1 (say) which has 6 headers, and various pages in the submenus. It all works fine.
I have another set of pages with accordion menu 2, which has 7 headers, and it all works fine. If, however, I am in menu 1, with header 3 open, and I then go to (the index page of) the second menu, the page will display with the 3 header open also. (I have persiststate: true in all pages). If I set this page to have persiststate: false and have a defaultexpanded:[0] set, it opens up the first header, which is fine. If I then open up the second header by clicking on it, the second submenu opens up, again OK. But if I click one of the submenu links, it goes to the correct page, but the accordion opens up the third header. The state of the accordion seems to be global across the site. Is it possible in the scenario I have described for the header which was open NOT to be remembered from accordion 1 (say) when the accordion 2 is accessed? Incidentally, thanks for a great piece of script that works really well.

ddadmin
02-08-2009, 06:11 PM
Make sure accordion menu 1 on page A and accordion menu 2 on page B use different CSS class names for its headers, namely, this value in the initialization code:


ddaccordion.init({
headerclass: "submenuheader", //Shared CSS class name of headers group
contentclass: "submenu", //Shared CSS class name of contents group
revealtype: "click", //Reveal content when user clicks or onmouseover the header? Valid value: "click" or "mouseover

The script uses the menu header's CSS class name for the cookie that stores its persistence state. If two menus on two different page both use the same class name, the script assumes they are the same menu.

due23
02-08-2009, 08:13 PM
Thanks for the quick reply, and the answer to my problem! All the best, Alan