Solved

Accorrdion Won't Open To Default Tab

Posted on 2014-07-24
5
127 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
  • 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
razorCMS: Change Menu Font 4 26
Test ddwrt:UserLookup 1 23
AWS CLI issues with Tags 3 31
Birthdays 3 14
I've been asked to discuss some of the UX activities that I'm using with my team. Here I will share some details about how we approach UX projects.
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

762 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now