PHPology is a collective of highly skilled, award winning, web gurus.
Contact Raj on 07985 467 213 or email [email protected]

Thickbox from content loaded via AJAX using jquery

Working on a project called Can You Draw The Internet? I was hit with a problem with my thickbox modal when content was loaded via AJAX. The thickbox modal would appear twice as the function TB_init() would be initiated twice. 

Searching the net, VinayRas came up with a solution that did the trick, the function highlighted below:

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;
  }
 );
}