PHPology.co.uk Collective of freelance web developers and designers

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

     

  • Comments

    0 comment(s)

    Be the first to comment!

    Add your comment
    Name*:
    Email*:
    Website URL (including full path e.g. http://www.yourwebsite.com/):
    Comment* (html/script tags will be removed):
    What do you see below?: