View Full Version : ajaxtabs "selected" on tabs other the the first

01-18-2008, 02:18 PM
1) Script Title: Ajax Tabs Content Script (v 2.0)

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex17/ajaxtabscontent/

3) Describe problem: I am not able to get the "selected" option to work when something other then the first tab has the selected class. It always goes to the first tab. It almost looks like it loads the 2nd tab, then the first. Am I doing some thing wrong? I know I had this working with the previous version of the script (which is completely different code). When we updated to the new version this went unnoticed for a while. I went to the demo.htm code and tried to get it working with "selected" on something other then the first tab, but it eghibits the same behavior...

Here is the code I'm trying.

<ul id="countrytabs" class="shadetabs">
<li><a href="external1.htm" rel="countrycontainer">Tab 1</a></li>
<li><a href="external2.htm" rel="countrycontainer" class="selected">Tab 2</a></li>
<li><a href="external3.htm" rel="countrycontainer">Tab 3</a></li>
<li><a href="external4.htm" rel="#iframe">Tab 4</a></li>

<div id="countrycontainer" style="border:1px solid gray; width:450px; margin-bottom: 1em; padding: 10px">
<p>This is some default tab content, embedded directly inside this space and not via Ajax.
It can be shown when no tabs are automatically selected, or associated with a certain tab,
in this case, the first tab.</p>

<script type="text/javascript">

var countries=new ddajaxtabs("countrytabs", "countrycontainer")
countries.setselectedClassTarget("link") //"link" or "linkparent"


01-18-2008, 05:52 PM

I foud the problem. There seems to be a bug in the ajaxtabs.js script. In the init function, there is a persisterror flag. This is triggering line 188 to execute, which sets the persisted tab to the first tab. It should only default to the first tab if no tab is marked as "selected". I fixed it by just commenting out this line. It would be nice if the logic that set the flag loaded the selected tab instead.