Results 1 to 5 of 5

Thread: Ajax Tabs - run scripts inside tabs

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

    Lightbulb Ajax Tabs - run scripts inside tabs

    This is great info! It get's me 99.9% to where I need to get for the project I'm currently working. I'm trying to set this up with the ajaxtabscontent script at:

    http://www.dynamicdrive.com/dynamici...axtabscontent/

    My last .1% is that my default tab is a content file that needs to run the onload script. see below:

    <ul id="maintab" class="shadetabs">
    <li class="selected"><a href="external.htm" rel="ajaxcontentarea" onmousedown="pollC('unique_1')" onmouseup="pollC('unique_1', 'load')">Intro</a></li>
    <li><a href="external.htm" rel="ajaxcontentarea" onmousedown="pollC('unique_1')" onmouseup="pollC('unique_1', 'load')">Bird</a></li>
    <li><a href="external2.htm" rel="ajaxcontentarea">Dog</a></li>
    <li><a href="external3.htm" rel="ajaxcontentarea">Cat</a></li>
    <li><a href="external4.htm" rel="ajaxcontentarea">Sea Otter</a></li>
    </ul>

    How can I get the default tab content to load without the onmousedown / onmouseup commands?

    Once I select another tab everything works great.

    Thanks

  2. #2
    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

    Then you need to run:

    Code:
    pollC('unique_1', 'load');
    onload of the page.
    - John
    ________________________

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

  3. #3
    Join Date
    Aug 2006
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Perfect!

    Thank you.

  4. #4
    Join Date
    Aug 2006
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question A little more help please...

    So far these scripts have been working great. I now have a new challenge. I'm using image map links to populate four div's with ajax content that need the same onload javascript. See below:

    <div>
    <map name="map" id="map">
    <area shape="circle" coords="58,28,30" alt="one"
    href="javascript:ajaxpage('../topics/DisplayCustomer_scrn.html', 'screenprint');
    javascript:ajaxpage('../topics/DisplayCustomer_step.html', 'steps');
    javascript:ajaxpage('../topics/DisplayCustomer_tip.html', 'tips');
    javascript:ajaxpage('../topics/DisplayCustomer_faq.html', 'faq')"
    onmousedown="pollC('unique_1')"
    onmouseup="pollC('unique_1', 'load')">

    <area shape="circle" coords="185,28,30" alt="two"
    href="javascript:ajaxpage('../topics/CustomerInformation_scrn.html', 'screenprint');
    javascript:ajaxpage('../topics/CustomerInformation_step.html', 'steps');
    javascript:ajaxpage('../topics/CustomerInformation_tip.html', 'tips');
    javascript:ajaxpage('../topics/CustomerInformation_faq.html', 'faq')"
    onmousedown="pollC('unique_1')"
    onmouseup="pollC('unique_1', 'load')">
    </map>
    </div>

    The when a link is selected the first time, all of the content pages load perfectly with the javascript functioning. When the next link is selected, the content pages load but "onload" javascript doesn't work until the link is double clicked.

    Can you point me in the right direction?

    Thanks

  5. #5
    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

    Image maps are tricky but, at the very least, because you are loading multiple contents, I would think you should be checking for the the id of the content that would take the longest to load. Better still, check for four id's. You shouldn't need so many javascript: thingers either:

    HTML Code:
    <area shape="circle" coords="58,28,30" alt="one"
    href="javascript:ajaxpage('../topics/DisplayCustomer_scrn.html', 'screenprint');
    ajaxpage('../topics/DisplayCustomer_step.html', 'steps');
    ajaxpage('../topics/DisplayCustomer_tip.html', 'tips');
    ajaxpage('../topics/DisplayCustomer_faq.html', 'faq')"
    onmousedown="pollC('unique_1');pollC('unique_2');pollC('unique_3');pollC('unique_4');"
    onmouseup="pollC('unique_1', 'load');pollC('unique_2', 'load');pollC('unique_3', 'load');pollC('unique_4', 'load');">
    You would need one span each with one of those unique_# id's, one unique span on each of the four external pages being loaded.

    You may have to customize pollC to these id's, if different scripts are needed for each external content page.

    Unique means unique. If it works in some cases only ever using unique_1, that is a quirk.
    - John
    ________________________

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

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
  •