Thickbox from content loaded via AJAX ( using jquery)

If you’re dealing with a lot of ajax calls in your pages, using thickbox might become a little tricky.

With my project, many tabs are loaded via ajax,

I have to re-parse the document (by manually calling TB_init each time tab content is loaded via ajax) to update links in the dynamically loaded content.

If you call TB_init twice over the same content, you can end up transforming your thickbox links twice.

To avoid this, I modified TB_init like so:

function TB_init(){
$(“a.thickbox”).click(function(){
var t = this.title || this.name || null;
var g = this.rel || false;
TB_show(t,this.href,g);
this.blur();
$(“a.thickbox”).removeClass(“thickbox”); // I added this line…
return false;
});
}

Vinay Yadav at VinayRas Infotech
Vinay Yadav Developer http://www.vinayras.com