PDA

View Full Version : Will AJAX Tabs Content work with ThickBox & jQuery?



joshywood
11-06-2006, 01:13 AM
1) Script Title: AJAX Tabs Content

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex17/ajaxtabscontent/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/showthread.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 (http://jquery.com/demo/thickbox/thickbox-code/thickbox.js) and jQuery (http://jquery.com/src/jquery-1.0.2.js). Here's the code for the pollC function:

pollC js function:

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

jscheuer1
11-06-2006, 03:41 AM
It looks like what you need is:

TB_init();

joshywood
11-06-2006, 03:52 AM
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

jscheuer1
11-06-2006, 04:46 AM
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.

joshywood
11-06-2006, 09:07 AM
Awesome, I'll test this out and post the results. Thanks!

- Josh

joshywood
11-06-2006, 09:54 AM
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 (http://www.carpe-edatum.com/thickbox/thickbox.html)

Thanks for your patience!

jscheuer1
11-06-2006, 10:11 AM
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.

joshywood
11-06-2006, 11:47 PM
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 :D I'll go ahead and start coding it right now and post the results in here. Thanks John!

- Josh