1) Script Title: Accordion Content script (v1.9)
2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...daccordion.htm
3) Describe problem: Does anyone know how to make all content items expanded by default?
1) Script Title: Accordion Content script (v1.9)
2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...daccordion.htm
3) Describe problem: Does anyone know how to make all content items expanded by default?
Do you know the total number of accordion contents in advanced? If so, you can just manually enter them (their indices) inside thedefaultexpandedoption:
Code:ddaccordion.init({ headerclass: "mypets", //Shared CSS class name of headers group contentclass: "thepet", //Shared CSS class name of contents group revealtype: "click", //Reveal content when user clicks or onmouseover the header? Valid value: "click", "clickgo", or "mouseover" mouseoverdelay: 200, //if revealtype="mouseover", set delay in milliseconds before header expands onMouseover collapseprev: false, //Collapse previous content (so only one open at any time)? true/false defaultexpanded: [0,1,2], //index of content(s) open by default [index1, index2, etc]. [] denotes no content. onemustopen: false, //Specify whether at least one header should be open always (so never all headers closed) animatedefault: false, //Should contents open by default be animated into view? persiststate: false, //persist state of opened contents within browser session? toggleclass: ["", "openpet"], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"] togglehtml: ["none", "", ""], //Additional HTML added to the header when it's collapsed and expanded, respectively ["position", "html1", "html2"] (see docs) animatespeed: "fast", //speed of animation: integer in milliseconds (ie: 200), or keywords "fast", "normal", or "slow" oninit:function(expandedindices){ //custom code to run when headers have initalized //do nothing }, onopenclose:function(header, index, state, isuseractivated){ //custom code to run whenever a header is opened or closed //do nothing } })
DD Admin
Sorry I don't, accordion contents are generated dynamically, could be 4 could be 30
If you have a variable (or can count something and make a variable) you could automatically insert that into the Javascript on the page using PHP or whatever language you're using to generate the menus.
Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum
In that case, try the below modified .js file. It lets you enter a keyword value of "all" for thedefaultexpandedoption to indicate that all headers should be expanded by default:
Code:ddaccordion.init({ headerclass: "mypets", //Shared CSS class name of headers group contentclass: "thepet", //Shared CSS class name of contents group revealtype: "click", //Reveal content when user clicks or onmouseover the header? Valid value: "click", "clickgo", or "mouseover" mouseoverdelay: 200, //if revealtype="mouseover", set delay in milliseconds before header expands onMouseover collapseprev: false, //Collapse previous content (so only one open at any time)? true/false defaultexpanded: "all", //index of content(s) open by default [index1, index2, etc]. [] denotes no content. onemustopen: false, //Specify whether at least one header should be open always (so never all headers closed) animatedefault: false, //Should contents open by default be animated into view? persiststate: false, //persist state of opened contents within browser session? toggleclass: ["", "openpet"], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"] togglehtml: ["none", "", ""], //Additional HTML added to the header when it's collapsed and expanded, respectively ["position", "html1", "html2"] (see docs) animatespeed: "fast", //speed of animation: integer in milliseconds (ie: 200), or keywords "fast", "normal", or "slow" oninit:function(expandedindices){ //custom code to run when headers have initalized //do nothing }, onopenclose:function(header, index, state, isuseractivated){ //custom code to run whenever a header is opened or closed //do nothing } })
DD Admin
If I do
defaultexpanded: "all"
Then nothing is expanded by default.
If I do
defaultexpanded: all
All is expanded by default, but then I lose the ability to contract content items.
Are you using the modified .js file attached in my above post?
DD Admin
Yes I am. Attached are the .js files that I am using.
The value "all" needs to be in quotations, so:
I just tested it again, and it does work in expanding all of the contents when the page first loads. It may be different for you if this is NOT the first time you've loaded that page within a browser session and you HAVE persistence enabled, as persistence starts to kick in for subsequent page loads.Code:defaultexpanded: "all"
DD Admin
Yes you are right, but then I don't have the capability to contract the expanded containers.
Here is the URL
http://goo.gl/2GBKq
Bookmarks