1) Script Title: Accordion menu
2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...enu-glossy.htm
3) Describe problem: Is it possible to open all menus at once on page load?
1) Script Title: Accordion menu
2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...enu-glossy.htm
3) Describe problem: Is it possible to open all menus at once on page load?
Just set the following two parameters when initializing a menu:
with 0,1 being the indices of your menu headers. Depending on the # of expandable headers you have, change this value.Code:collapseprev: false, //Collapse previous content (so only one open at any time)? true/false defaultexpanded: [0,1], //index of content(s) open by default [index1, index2, etc] [] denotes no content
You may also want to set persist to false:
Code:persiststate: false, //persist state of opened contents within browser session?
DD Admin
Sure, find this line in the beginning of your code:
and add numbers in the brackets, starting with zero:Code:defaultexpanded: [], //index of content(s) open by default [index1, index2, etc] [] denotes no content
So if you have five menus, you count to four.Code:defaultexpanded: [0,1,2,3,4], //index of content(s) open by default [index1, index2, etc] [] denotes no content
Good luck!
Thanks a lot! I'll give that a shot.
Oh wait, this makes all the menu items open at once on every page (I use an SSI type tool to include the header code on every page). Is it possible to make it all open only on pages that have less than 5 menu items?
You can get the headers to expand conditionally based on how many headers there are in total on the page by doing the below:
1) Keep the changes suggested above for the parameter settings except "defaultexpanded". Revert it back to none:
Then use the oninit() parameter/ event handler to dynamically expand all the headers if there are less than 5 headers total on the page:Code:defaultexpanded: [],
Code:oninit:function(headers, expandedindices){ //custom code to run when headers have initalized var limit=Math.min(headers.length, 5) for (var i=0; i<limit; i++) ddaccordion.expandone(this.headerclass, i) },
DD Admin
Bookmarks