Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Default Expand all for Accordion Content script (v1.9)

  1. #1
    Join Date
    Nov 2007
    Posts
    16
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Default Expand all for Accordion Content script (v1.9)

    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?

  2. #2
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Do you know the total number of accordion contents in advanced? If so, you can just manually enter them (their indices) inside the defaultexpanded option:

    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

  3. #3
    Join Date
    Nov 2007
    Posts
    16
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    Sorry I don't, accordion contents are generated dynamically, could be 4 could be 30

  4. #4
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    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

  5. #5
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Quote Originally Posted by orbitrod View Post
    Sorry I don't, accordion contents are generated dynamically, could be 4 could be 30
    In that case, try the below modified .js file. It lets you enter a keyword value of "all" for the defaultexpanded option 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

  6. #6
    Join Date
    Nov 2007
    Posts
    16
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    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.

  7. #7
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Are you using the modified .js file attached in my above post?
    DD Admin

  8. #8
    Join Date
    Nov 2007
    Posts
    16
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    Yes I am. Attached are the .js files that I am using.

  9. #9
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    The value "all" needs to be in quotations, so:

    Code:
    defaultexpanded: "all"
    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.
    DD Admin

  10. #10
    Join Date
    Nov 2007
    Posts
    16
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •