ThickBox problem with jQuery 1.3

April 2, 2009

ThickBox (external link) script stops working after upgrading to jQuery 1.3. The culprit that breaks the code is the old syntax for the attribute selector. The fix is quite simple.

To make the thickbox script compatible with the latest jQuery version, all you need to do is to update the syntax for the attribute selector: [attr=value] instead of [@attr=value].

Search in thickbox.js (on line 79) for:

TB_TempArray = $("a[@rel="+imageGroup+"]").get();

and replace it with:

TB_TempArray = $("a[rel="+imageGroup+"]").get();

As Karl Swedberg (external link) explains [1]:

By far the most common stumbling block to the 1.3 upgrade has been the attribute selector. The XPath syntax for this selector — [@attribute] — has been deprecated since version 1.1.4 in August, 2007. Still, many scripts, including some prominent plugins, continued to use the old syntax, which wasn't a problem until jQuery 1.3, at which point it was no longer supported. The correct syntax (since 1.1.4) follows the CSS standard: [attribute].

Karl Swedberg