PDA

View Full Version : AJAX Tabs Default Load Tab Not Working



swiftmed
12-09-2007, 12:37 AM
1) Script Title: AJAX Tabs

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

3) Describe problem:

I know that you can set a specific tab to be shown by default when a page loads, by adding "rel="#default"" to the tab, however when going to one page on my site and selecting a tab, for example "features", if you then go to another page on my site which also contains the ajax tabs script with different content, the default tab is not being shown by default. the tab which was selected on the last page is shown on instead.

Here is a copy of the code for the tab i want to be shown by default:


<li><a href="#" class="selected" rel="#default">Benefits</a></li>

Can anybody tell me why this tab is not being shown by default after visiting the page?

Here is where the script is being run. there are 4 pages in total, with a version of AJAX Tabs working on each page with different content.

1. http://swiftmediauk.co.uk/logo-designer.php
2. http://swiftmediauk.co.uk/custom-logo-design.php
3. http://swiftmediauk.co.uk/affordable-logo-design.php
4. http://swiftmediauk.co.uk/company-logo-design.php

ddadmin
12-10-2007, 07:02 AM
The selected tab is persisted across those pages because you're using the same variable "countries" on each of these pages when initializing a tab instance. Try changing this variable to something else for each page, so they are unique.

On a different note, you've repeated the initialization code twice on some pages, for example:


<script type="text/javascript">

var countries=new ddajaxtabs("countrytabs", "countrydivcontainer")
countries.setpersist(true)
countries.setselectedClassTarget("link") //"link" or "linkparent"
countries.init()

</script>
<script type="text/javascript">

var countries=new ddajaxtabs("countrytabs", "countrydivcontainer")
countries.setpersist(true)
countries.setselectedClassTarget("link") //"link" or "linkparent"
countries.init()

</script>

You should remove the duplicate where they exist.

BTW, please note that your page is currently in violation of our usage terms, since the credit notice doesn't appear inline on the page. Please reinstate the credit notice: http://www.dynamicdrive.com/notice.htm

swiftmed
12-10-2007, 06:52 PM
Hiya,

thank you for your feedback. i will make the changes you suggested, and will see whether that makes a difference. additionally, i wasn't aware about the credit notice violation, and i will also put that right when making the suggested changes this evening.

I will post back here with the results. Thanks again for your support. you offer a great service for designers like myself.

swiftmed
12-10-2007, 11:56 PM
Hi there,

i made the changes you mentioned, and im still having the same problem. well at least i think ive made the changes you were talking about. here are examples of the code ive used for each of the pages now:


<script type="text/javascript">

var countriesbronze=new ddajaxtabs("countrytabs", "countrydivcontainer")
countriesbronze.setpersist(true)
countriesbronze.setselectedClassTarget("link") //"link" or "linkparent"
countriesbronze.init()

</script>


<script type="text/javascript">

var countriessilver=new ddajaxtabs("countrytabs", "countrydivcontainer")
countriessilver.setpersist(true)
countriessilver.setselectedClassTarget("link") //"link" or "linkparent"
countriessilver.init()

</script>


<script type="text/javascript">

var countriesplatinum=new ddajaxtabs("countrytabs", "countrydivcontainer")
countriesplatinum.setpersist(true)
countriesplatinum.setselectedClassTarget("link") //"link" or "linkparent"
countriesplatinum.init()

</script>


<script type="text/javascript">

var countriesgold=new ddajaxtabs("countrytabs", "countrydivcontainer")
countriesgold.setpersist(true)
countriesgold.setselectedClassTarget("link") //"link" or "linkparent"
countriesgold.init()

</script>

Is that correct and what you were talking about, or did i mis-understand what you were pointing out? I really appreciate your advice.

Thanks

ddadmin
12-11-2007, 12:28 AM
Actually, my mistake. What I mean is that the IDs of each of the tabs containers on these pages should be unique. So something like:


<script type="text/javascript">

var countries=new ddajaxtabs("silvertabs", "countrydivcontainer")
countries.setpersist(true)
countries.setselectedClassTarget("link") //"link" or "linkparent"
countries.init()

</script>


<script type="text/javascript">

var countries=new ddajaxtabs("goldtabs", "countrydivcontainer")
countries.setpersist(true)
countries.setselectedClassTarget("link") //"link" or "linkparent"
countries.init()

</script>


<script type="text/javascript">

var countries=new ddajaxtabs("graytabs", "countrydivcontainer")
countries.setpersist(true)
countries.setselectedClassTarget("link") //"link" or "linkparent"
countries.init()

</script>


<script type="text/javascript">

var countries=new ddajaxtabs("bronzetabs", "countrydivcontainer")
countries.setpersist(true)
countries.setselectedClassTarget("link") //"link" or "linkparent"
countries.init()

</script>

The script uses the tab's ID value as the cookie name, so if multiple pages all share the same IDs, the same cookie value will be used. Be sure to update the ID values in your tabs DIV element to match what you have set inside the initialization script above.

swiftmed
12-11-2007, 12:52 AM
Actually, my mistake. What I mean is that the IDs of each of the tabs containers on these pages should be unique. So something like:


<script type="text/javascript">

var countries=new ddajaxtabs("silvertabs", "countrydivcontainer")
countries.setpersist(true)
countries.setselectedClassTarget("link") //"link" or "linkparent"
countries.init()

</script>


<script type="text/javascript">

var countries=new ddajaxtabs("goldtabs", "countrydivcontainer")
countries.setpersist(true)
countries.setselectedClassTarget("link") //"link" or "linkparent"
countries.init()

</script>


<script type="text/javascript">

var countries=new ddajaxtabs("graytabs", "countrydivcontainer")
countries.setpersist(true)
countries.setselectedClassTarget("link") //"link" or "linkparent"
countries.init()

</script>


<script type="text/javascript">

var countries=new ddajaxtabs("bronzetabs", "countrydivcontainer")
countries.setpersist(true)
countries.setselectedClassTarget("link") //"link" or "linkparent"
countries.init()

</script>

The script uses the tab's ID value as the cookie name, so if multiple pages all share the same IDs, the same cookie value will be used. Be sure to update the ID values in your tabs DIV element to match what you have set inside the initialization script above.

Hiya,

That worked absolutely perfectly. thanks so much for your help. it is exactly what i was looking for! being free was just a bonus so thank you.