Results 1 to 7 of 7

Thread: Nested Ajaxtabs?

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

    Unhappy Nested Ajaxtabs?

    Source: http://www.dynamicdrive.com/dynamici...tent/index.htm
    Multiple ajaxtabs work perfectly but nested ajaxtabs dont
    For example:
    This works
    <ul id="maintab" class="shadetabs">
    <li><a href="external.htm" rel="ajaxcontentarea">Bird</a></li>
    <li><a href="external2.htm" rel="ajaxcontentarea">Dog</a></li>
    </ul>

    <div id="ajaxcontentarea" class="contentstyle">
    <p>Default Content...</p>
    </div>

    <ul id="newstab" class="shadetabs">
    <li><a href="local.htm" rel="ajaxcontentarea">Local</a></li>
    <li><a href="world.htm" rel="ajaxcontentarea">World</a></li>
    </ul>

    <script type="text/javascript">
    startajaxtabs("maintab", "newstab")
    </script>
    But this does not work
    <ul id="maintab" class="shadetabs">
    <li><a href="external.htm" rel="ajaxcontentarea">Bird</a></li>
    <li><a href="external2.htm" rel="ajaxcontentarea">Dog</a></li>
    </ul>

    <div id="ajaxcontentarea" class="contentstyle">
    <ul id="newstab" class="shadetabs">
    <li><a href="local.htm" rel="ajaxcontentarea">Local</a></li>
    <li><a href="world.htm" rel="ajaxcontentarea">World</a></li>
    </ul>
    </div>

    <script type="text/javascript">
    startajaxtabs("maintab", "newstab")
    </script>
    It still works if I only click Bird and Dog but if I click Bird then Local or World the I takes me to the local.htm or world.htm page.

    Please help! I know you might not support this kind of question but I really need this for my website so please help me
    Thanks in advance

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    I'm not sure how to fix it, but I would guess it's more of an issue with using two scripts on the same page... variables, functions, etc that are the same, more than compatibility of having one inside the other.

    you should use two copies of the script, with differently named variables and functions....

    We'll see if someone else can figure out the specifics... but also remember that questions about two scripts are realy time intensive to figure out... so not sure how quickly people will figure it out...
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

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

    Default

    Hmm there's definitely no easy way to get "nested tabs" to work, since the "contentarea" space is completely overwritten by the script with the contents of the external page. As you already know, this is very different from having multiple Ajax tabs on the same page, which works fine.

  4. #4
    Join Date
    Jun 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    are you looking for your code to do something similar to this?
    http://www.re-inventing.com/dev/caus.../example2.html

  5. #5
    Join Date
    Jul 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default An interesting following; it runs but...

    Hello, I'm new in this forum...
    I've tried a lot with nested Ajaxtabs, and I've found some interesting things.
    1) My proposed solution is to add a nonstandatd "sta" attribute in addition to "href" and "rel". This attribute should contain the ID of the "nested" (i.e. dynamically created at loading of the sub-page) <ul> list, and has to be activated dynamically just after "nested" page loading. See:

    function startajaxtabs(){
    ...
    ulistlink.onclick=function(){
    ajaxpage(this.getAttribute("href"), this.getAttribute("rel"), this)

    alert("Loaded AJAX "+this.getAttribute("href")) // LOOK HERE

    loadobjs(this.getAttribute("rev"))
    /* From here */
    if(this.getAttribute("sta")) {
    startajaxtabs(this.getAttribute("sta"))
    }
    /* to here */
    return false
    }
    ...
    }

    (startajaxtabs can be re-entrant since it doesn't use global vars)

    ...and now the BAD news. If you miss the "alert" just after the dynamic page loading, the script DOESN'T run.
    After a lot of attempts and debugging I'm sure that this side effect is due to a sort of "browser reset" during the "alert".
    In fact, the same effect can be accomplished if you set a debugger break just after the "ajaxpage(...)" call.
    If no "alert" or "stop for debugging" is done, script fails since the nested

    var ulobj=document.getElementById(arguments[i])

    is NOT able to find the "nested" <ul> just created via AJAX.

    My impression is that the "innerHTML" implementation is not perfect.

    Very oddly, you'll see the SAME problem and solution for both IE6 and FF1.5.

    Somehow complex, huh? Waiting for comments.

    If someone has found a solution with different scripts, please give me an hint.

  6. #6
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Polling is one method to initialize content that is coming but that may or may not be there yet. When you start the call or just after the call for the imported content, you can also start a poll. Generally a poll can check for a unique element at the end of the imported content. Once this element is found, it can run the initialization, until then, the poll may set a timeout that restarts the poll.

    This was worked out to allow lightbox (which needs to init its content) to run on content loaded via Dynamic Ajax Content in this thread:

    http://www.dynamicdrive.com/forums/s...ad.php?t=11098
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  7. #7
    Join Date
    Jul 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Talking

    Quote Originally Posted by federico
    ...and now the BAD news. If you miss the "alert" just after the dynamic page loading, the script DOESN'T run.
    Aha, found a solution!
    this is the chunk:

    ulistlink.onclick=function(){
    ajaxpage(this.getAttribute("href"), this.getAttribute("rel"), this)
    loadobjs(this.getAttribute("rev"))
    if(this.getAttribute("sta")) {
    setTimeout("startajaxtabs('" + this.getAttribute("sta") + "')", 1000)
    }
    return false
    }

    It runs perfectly!

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
  •