I think I've seen this subject before, so I thought I'd share my solution.
Case:
- I want to use Thickbox
- Some of my content is dynamically provided through AJAX
- The Thickbox urls in the AJAX content aren't thickboxed in $(document).ready()
- Thickboxing twice gives me errors
My solution:
I changed the TB_init from Thickbox to:
function TB_init(elem) {
if (!elem) elem = document;
$("a.thickbox", elem).click(function() {
var t = this.title || this.name || null;
var g = this.rel || false;
TB_show(t,this.href,g);
this.blur();
return false;
});
}
Now I can provide this function with a DOM element to search in. So
when I load content into <div id="ajaxHere"></div>, I can call
TB_init($("#ajaxHere")[0]).
I might even extend this by adding a $.fn.thickbox that does this for
the entire jQuery chain to make it look better and play nice with
other jQuery stuff, but I'm hoping Cody might want to add some of this
into Thickbox.
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/