[jQuery] Thickbox on Demand Plugin

[jQuery] Thickbox on Demand Plugin

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Hello everbody,
I know it doesn't take a genius to figure this one out, but since the
Thickbox seems to be pretty popular in the community here comes a
little plugin that can be used to make a given set of elements (links)
use Thickbox on the fly. I needed it because I had some images that are
inserted via Textile into my page, and I didn't want to hack the
Textile lib to add the thickbox class to all of them:
------------------------------------------------------------
<tt>$.fn.useThickbox = function()
{
    return this.each(function()
    {
        $(this).click(function()
        {
            var t = this.title || this.name || null;
            var g = this.rel || false;
            TB_show(t,this.href,g);
            this.blur();
            return false;
        });
    });
}</tt>
------------------------------------------------------------
So a sample usage would be:
$('a > img').parent().useThickbox();
Which would make all links containing image elements automatically use
the almighty thickbox to display them. As you can see in the code above
I simply copied TB_init function for all of this. Nevertheless I hope
this might be helpful to somebody else ; ).
-- Felix Geisendörfer aka the_undefined
<div class="moz-signature"><small>--------------------------
<a href="http://www.thinkingphp.org">http://www.thinkingphp.org</a>
<a href="http://www.fg-webdesign.de">http://www.fg-webdesign.de</a>
</small></div>
</body>
</html>
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/