Results 1 to 8 of 8

Thread: Will AJAX Tabs Content work with ThickBox & jQuery?

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

    Question Will AJAX Tabs Content work with ThickBox & jQuery?

    1) Script Title: AJAX Tabs Content

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...tent/index.htm

    3) Describe problem: I'll try to make this as simple as possible. I've got the AJAX Tabs running fine. I have links within the content area of the tabs that, when clicked, I want to load pictures dynamically using ThickBox.js (If you're not familiar with ThickBox here's the link: http://jquery.com/demo/thickbox/) ThickBox is written in javascript and runs on top of the jQuery library. I realize that external js can be loaded within the AJAX Tabs content area by use of the pollC function (If you're not familiar with the pollC function here's a link: http://www.dynamicdrive.com/forums/s...ad.php?t=13003). But as a requirement, the onload events that trigger the external js files you want to use must be known and placed into the pollC script. I'm new to both traditional javascript and jQuery. Can anyone please tell me what onload functions I need from the ThickBox.js and the jQuery.js to place into the pollC script so that I can make this all work? Here are links to the code of ThickBox and jQuery. Here's the code for the pollC function:

    pollC js function:
    Code:
    <script type="text/javascript">
    function pollC(id, load){
    if (!load&&document.getElementById(id)){
    document.getElementById(id).id='';
    return;
    }
    else if (load&&document.getElementById(id)){
    if (id=='unique_1')  //optional
    onloadfunct();  //required
    return;
    }
    else if (load&&!document.getElementById(id))
    setTimeout("pollC('"+id+"', 'load')", 60);
    }
    </script>

  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

    It looks like what you need is:

    TB_init();
    - John
    ________________________

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

  3. #3
    Join Date
    Nov 2006
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    So I don't need to use an onload function for jQuery.js, just the ThickBox.js? Because the instructions for running ThickBox requires jQuery.js and ThickBox.js to be included in the head of the document with jQuery.js placed before ThickBox.js. TB_init() initializes the ThickBox.js, will I not need a trigger for the jQuery.js? Thanks so much for your help by the way

    - Josh

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

    I didn't by any means test this out but, by looking through the two files, it appears as though jQuery is just a library of routines, some of which ThickBox uses. Generally you can test if this is all that is required by putting the external script tags on your 'top' page, and loading some ThickBox content in via Ajax without having pollC or any of the calls to it on the page at all. Once you've loaded the content in, it shouldn't work. This is the problem you are having. At this very point, paste this into the address bar and hit enter:

    javascript:void(TB_init())

    This will test if the TB_init(); call is all that is required. If so, the newly Ajax loaded ThickBox content should now be initialized and ready to use. The successful completion of this test means that the pollC function will work for you using just the TB_init(); call.
    - John
    ________________________

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

  5. #5
    Join Date
    Nov 2006
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Awesome, I'll test this out and post the results. Thanks!

    - Josh

  6. #6
    Join Date
    Nov 2006
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post

    Ok, I added the javascript:void(TB_init()) call to the address bar of the browser and hit enter, but nothing took place on the page, not even a refresh. I intuitively feel like what I'm trying to accomplish is probably easy for someone with greater knowledge. But to help clarify my goal, I've provided a link to a page with ThickBox running on it. Simply click the link that says "Click To Test". The resulting effect you get is all I want to accomplish, with the only exception that it take place from within the AJAX Tabs content area. Here's the demo link:
    My personal ThickBox example

    Thanks for your patience!

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

    Ok, I added the javascript:void(TB_init()) call to the address bar of the browser and hit enter, but nothing took place on the page, not even a refresh.
    Nothing was supposed to happen except that you should then be able to use the ThickBox effect upon clicking the content for it.
    - John
    ________________________

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

  8. #8
    Join Date
    Nov 2006
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Ahhh, I see. Yes, that worked! So based on that, simply including the TB_init() as the trigger in the pollC script will presumably have everything working correctly I'll go ahead and start coding it right now and post the results in here. Thanks John!

    - Josh

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
  •