Results 1 to 6 of 6

Thread: AJAX Tabs Default Load Tab Not Working

  1. #1
    Join Date
    May 2006
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default AJAX Tabs Default Load Tab Not Working

    1) Script Title: AJAX Tabs

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...axtabscontent/

    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:

    Code:
    <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

  2. #2
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    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:

    Code:
      <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

  3. #3
    Join Date
    May 2006
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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.

  4. #4
    Join Date
    May 2006
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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:

    Code:
      <script type="text/javascript">
    
    var countriesbronze=new ddajaxtabs("countrytabs", "countrydivcontainer")
    countriesbronze.setpersist(true)
    countriesbronze.setselectedClassTarget("link") //"link" or "linkparent"
    countriesbronze.init()
    
    </script>
    Code:
    <script type="text/javascript">
    
    var countriessilver=new ddajaxtabs("countrytabs", "countrydivcontainer")
    countriessilver.setpersist(true)
    countriessilver.setselectedClassTarget("link") //"link" or "linkparent"
    countriessilver.init()
    
    </script>
    Code:
    <script type="text/javascript">
    
    var countriesplatinum=new ddajaxtabs("countrytabs", "countrydivcontainer")
    countriesplatinum.setpersist(true)
    countriesplatinum.setselectedClassTarget("link") //"link" or "linkparent"
    countriesplatinum.init()
    
    </script>
    Code:
    <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

  5. #5
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    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:

    Code:
      <script type="text/javascript">
    
    var countries=new ddajaxtabs("silvertabs", "countrydivcontainer")
    countries.setpersist(true)
    countries.setselectedClassTarget("link") //"link" or "linkparent"
    countries.init()
    
    </script>
    Code:
    <script type="text/javascript">
    
    var countries=new ddajaxtabs("goldtabs", "countrydivcontainer")
    countries.setpersist(true)
    countries.setselectedClassTarget("link") //"link" or "linkparent"
    countries.init()
    
    </script>
    Code:
    <script type="text/javascript">
    
    var countries=new ddajaxtabs("graytabs", "countrydivcontainer")
    countries.setpersist(true)
    countries.setselectedClassTarget("link") //"link" or "linkparent"
    countries.init()
    
    </script>
    Code:
    <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.

  6. #6
    Join Date
    May 2006
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by ddadmin View Post
    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:

    Code:
      <script type="text/javascript">
    
    var countries=new ddajaxtabs("silvertabs", "countrydivcontainer")
    countries.setpersist(true)
    countries.setselectedClassTarget("link") //"link" or "linkparent"
    countries.init()
    
    </script>
    Code:
    <script type="text/javascript">
    
    var countries=new ddajaxtabs("goldtabs", "countrydivcontainer")
    countries.setpersist(true)
    countries.setselectedClassTarget("link") //"link" or "linkparent"
    countries.init()
    
    </script>
    Code:
    <script type="text/javascript">
    
    var countries=new ddajaxtabs("graytabs", "countrydivcontainer")
    countries.setpersist(true)
    countries.setselectedClassTarget("link") //"link" or "linkparent"
    countries.init()
    
    </script>
    Code:
    <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.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •