Solved

Accorrdion Won't Open To Default Tab

Posted on 2014-07-24
5
131 Views
Last Modified: 2014-08-01
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
Comment
Question by:Computer Guy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 58

Expert Comment

by:Gary
ID: 40217238
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
 
LVL 3

Author Comment

by:Computer Guy
ID: 40217259
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
 
LVL 58

Expert Comment

by:Gary
ID: 40217272
Post a link to the page or post your whole code - line 87 means nothing to me
0
 
LVL 3

Author Comment

by:Computer Guy
ID: 40231870
0
 
LVL 58

Accepted Solution

by:
Gary earned 500 total points
ID: 40232126
In ddaccordion.js
look for
var persistedheaders=ddaccordion.getCookie(config.headerclass)

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

Featured Post

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
ebay messages api 6 17
Jquery form 9 39
HTML editor custom button 3 56
Get Text of Select using class name ***JavaScript Only*** 3 12
Learn by example how to specify CSS selectors for Selenium WebDriver test automation software.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question