Page 1 of 3 123 LastLast
Results 1 to 10 of 25

Thread: defaultexpanded option in Accordion Content script doesn't work

  1. #1
    Join Date
    Jun 2009
    Posts
    20
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default defaultexpanded option in Accordion Content script doesn't work

    1) Script Title: Accordion Content script

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...daccordion.htm

    3) My problem:
    just yesterday I've installed the Accordion Content script, but it happens that the "defaultexpanded" option doesn't work, it works only if the "persiststate" option is set to false. Following my ddaccordion.init code:

    Code:
    ddaccordion.init({
    	headerclass: "menuTitle", //Shared CSS class name of headers group
    	contentclass: "menuContent", //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: true, //Collapse previous content (so only one open at any time)? true/false 
    	defaultexpanded: [0], //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: true, //persist state of opened contents within browser session?
    	toggleclass: ["closedHeader", "openHeader"], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
    	togglehtml: ["suffix", "<img src='images/plus.gif' width='18' height='18'>", "<img src='images/minus.gif' width='18' height='18'>"], //Additional HTML added to the header when it's collapsed and expanded, respectively  ["position", "html1", "html2"] (see docs)
    	animatespeed: "normal", //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
    	}
    })

    Here is one page of my site where you can see the menus (on the right):
    http://www.sba.unifi.it/CMpro-v-p-60.html

    I've also tried to disable all other javascripts to check out if it depends on some interactions with one of these scripts, but nothing has changed, so why the "defaultexpanded" option doesn't work when "persiststate" is true? Can you help me?

    Thanks
    Last edited by urbini; 06-11-2009 at 06:27 AM.

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

    Default

    When persist state is enabled, the very first time the page loads, the 1st content should be expanded by default (due to defaultexpanded set to [0]). Is this not the case?
    DD Admin

  3. #3
    Join Date
    Jun 2009
    Posts
    20
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    No, this doesn't happen. I've also tried to disable all other javascripts to check out if it depends on some interactions with one of these scripts, but nothing has changed. It only works when "persiststate" is set to false.
    Furthermore, I've found a thread in the forum about the same problem (http://www.dynamicdrive.com/forums/s...ad.php?t=33440), it was about one year ago, but it was because of the new version of jquery (1.2.6) and at the end you answered that the bug was fixed in the new version of the accordion script.

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

    Default

    When testing, since you have "persiststate" enabled, note that you need to close and relaunch the browser once each time you view the page in order to get an accurate result. After the initial page view, the script remembers the last expanded DIV and recalls that when you reload the page.

    I just created a blank page with just the Accordion script on it, and have the following settings:

    Code:
    	headerclass: "mypets", //Shared CSS class name of headers group
    	contentclass: "thepet", //Shared CSS class name of contents group
    	revealtype: "mouseover", //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: true, //Collapse previous content (so only one open at any time)? true/false 
    	defaultexpanded: [1], //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: true, //persist state of opened contents within browser session?
    As expected, the first time the page loads, the 2nd DIV is expanded by default. If I reload the page, the DIV that gets expanded becomes the last one that was expanded just before I reloaded the page.
    DD Admin

  5. #5
    Join Date
    Jun 2009
    Posts
    20
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    I've made a further test: saving the page in my pc (win xp pro) through the browser (File > Save page as > Complete web page), then the script works as expected.
    Differently, this doesn't happen both in the on line site and in the local version of it which run through EasyPHP (in both cases the version of php is 4.x), where persiststate=true seems to disturb the defaultexpanded option.
    So: it's because of some configurations of apache or php?? I really can't understand!

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

    Default

    What happens if you create a blank page with just the original, unmodified Accordion menu (from the code you cut and paste on the script page), and upload that page to your server? Does it still misbehave?
    So: it's because of some configurations of apache or php?? I really can't understand!
    It shouldn't make any difference.
    DD Admin

  7. #7
    Join Date
    Jun 2009
    Posts
    20
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    I made the test you suggested, a new blank page works correctly, so it doesn't depend on some server's configuration. So, maybe it depends on some configuration of the CMS we use (MDPro, http://www.maxdev.it/)? But we use several javascripts and it's the first time that one script doesn't work correctly.

  8. #8
    Join Date
    Jun 2009
    Posts
    4
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    When persist state is enabled, the very first time the page loads, the 1st content should be expanded by default (due to defaultexpanded set to [0]).
    I need to have all levels closed when the page loads the first time - and persist state enabled. How would I achieve this?

    Thanks in advance.

  9. #9
    Join Date
    Jun 2009
    Posts
    20
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Reading the instructions, you have to set the following:
    Code:
    .....
    defaultexpanded: [],
    persiststate: true,
    .....

  10. #10
    Join Date
    Jun 2009
    Posts
    4
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    Thanks, I just checked and I had it configured as [0]!

    Brilliant, and many thanks for such a quick reply!

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
  •