View Full Version : AJAX Tabs Script - Stop caching of default tabs

09-03-2008, 05:38 PM
I am using the Ajax Tabs Content Script (v 2.2) script from the Dynamic Content archive
I have run into an issue with what seems to be a caching issue with any tab that is a default tab.

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

In my interface I have some edit-in-place scripts going on and lets say for instance if you edit a field on tab1 (a default tab) and then click to another tab when you go back to tab1 you get the snapshot in time that was loaded when the page was first loaded and you then have to do a full page refresh to get see the updated data again.

I noticed there is a "cache busting" feature for external links and that works well for the external files... any ideas on how to bust the cache on the default tabs?

09-04-2008, 03:46 AM
This happens because the script merely captures the HTML for the default contents once when the page loads, then uses that whenever the default tab is selected. It does this because the entire content container is overwritten each time a tab is selected, so capturing is required.

A workaround is to tell the script to look for the default content within a container defined outside the content container on your page. That way that content is never overwritten. To do this, first, use the below modified version of the .js file. Then in your HTML, instead of the usual:

<div id="countrydivcontainer" style="border:1px solid gray; width:450px; margin-bottom: 1em; padding: 10px">
Your default contents used to go here

Do the following instead:

<div id="countrydivcontainer" style="border:1px solid gray; width:450px; margin-bottom: 1em; padding: 10px">

<p id="defaultcontentcontainer" style="display:none">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", "countrydivcontainer", "defaultcontentcontainer")
countries.setselectedClassTarget("link") //"link" or "linkparent"


09-04-2008, 05:16 PM
Cool... my only other question would be would this update to the script also account for multiple default tabs?... I am using that update that was posted here:


In some cases I have 2 or 3 default tabs on the page.