[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 143
  • Last Modified:

Accorrdion Won't Open To Default Tab

Hi, using this accordion: the goal is to get the first item to be the default, so when someone is on the 3rd header, then hit refresh, the first one will be default.

Not sure what I'm doing wrong

http://www.dynamicdrive.com/dynamicindex17/ddaccordionmenu-bullet.htm?expandable=3

defaultexpanded: [0]

   ddaccordion.init({
	  headerclass: "expandable", //Shared CSS class name of headers group that are expandable
	  contentclass: "categoryitems", //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: true, //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: ["", "openheader"], //Two CSS classes to be applied to the header when it's collapsed and expanded, respectively ["class1", "class2"]
	  togglehtml: ["prefix", "", ""], //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(headers, 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
	  }
  })

 <h3 class="menuheader expandable">Blah</h3>
                                    <ul class="categoryitems">
                                        <li><a href="http://www.google.com/">Blah</a></li>
                                        <li><a href="http://www.google.com/">Blah</a></li>
                                        <li><a href="http://www.google.com/">Blah</a></li>
                                    </ul>
                                <h3 class="menuheader expandable">Blah</h3>
                                    <ul class="categoryitems">
                                        <li><a href="http://www.google.com/">Blah</a></li>
                                        <li><a href="http://www.google.com/">Blah</a></li>
                                        <li><a href="http://www.google.com/">Blah</a></li>
                                        <li><a href="http://www.google.com/">Blah</a></li>
                                    </ul>
                                <h3 class="menuheader expandable">Blah</h3>
                                    <ul class="categoryitems">
                                        <li><a href="http://www.google.com" target="_blank">Blah</a></li>
                                    </ul>
                                  <h3 class="menuheader expandable">Blah</h3>
                                    <ul class="categoryitems" id="last-ui" style="">
                                        <li><a href="http://www.google.com/">Blah</a></li>
                                        <li><a href="http://www.google.com/">Blah</a></li>
                                    </ul>

Open in new window

0
Computer Guy
Asked:
Computer Guy
  • 3
  • 2
1 Solution
 
GaryCommented:
And what is it doing now?
The menu will always default to the deafult value unless you are manually changing the url like they do on DD with a link.
0
 
Computer GuyAuthor Commented:
If I am on line 87 of my code (3rd section), and hit refresh, it stays on line 87 instead of going back to the 1st section.
0
 
GaryCommented:
Post a link to the page or post your whole code - line 87 means nothing to me
0
 
Computer GuyAuthor Commented:
0
 
GaryCommented:
In ddaccordion.js
look for
var persistedheaders=ddaccordion.getCookie(config.headerclass)

After this line add
persistedheaders="0c";
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now