Thickbox and jQuery 1.3.1

I've recently been finishing off a site where I needed a lightbox to simplify showing several photos for each product. I've used Thickbox in the past, as it comes with Wordpress by default, however this is a custom built site. I already had the latest version of jQuery running for other functions on the site, so just needed to grab a copy of thickbox, upload that, add the necessary code and that should be that.

3 hours of going around in circles later… and still no joy! After checking over my code piece by piece, trying the code out of WordPress, trying the page on another server just in case, and trying every other option I could think of, I finally tried uploading jQuery 1.2.6 from my WordPress 2.7 folder on my computer, and hey presto, it all worked!

It seems that there is a minor change required for thickbox to work with the latest jQuery version. After a bit of searching around I found out that what's needed is on line 79 of the existing thickbox file you need to change the line

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

to not include the @ sign in it ie.

New Thickbox Code
  1. TB_TempArray = $("a[rel="+imageGroup+"]").get();

Such a simple change that caused a few hours of frustration! So hopefully it may be of use to someone else :)

63 Responses to “Thickbox and jQuery 1.3.1”

  1. It's clever stuff and clever stuff means complicated code with increased chances of things breaking and not working on different browsers. I'd like to see a usability study on whether people like this style of mini windows popping up inside their main browser window.

    By Chris Kent on Mon, 16 February, 2009

  2. Well, the problem here is/was just that thickbox hadn't been upgraded to work with the latest version of jQuery. jQuery supports all the latest browsers and some earlier ones too. I don't think thickbox has been updated for quite a while, possibly because the creator doesn't have the time. As for a usability study, it's perfectly fine from a usability point of view. Whether people like it or not is not usability but just personal preference. I think that a simple lightbox is an effective way of displaying a gallery of images. It's clean, quick and saves on having to create another page to display the image.

    By Sarah on Wed, 18 February, 2009

  3. Hey, thanks a lot! I had the same problem and was searching for an hour now.

    By Eric on Thu, 19 February, 2009

  4. I know the feeling! I lost about half a day on it, knowing I could use something else but frustrated and confused as to why this simple script wasn't working!

    By Sarah on Wed, 25 February, 2009

  5. Thank you so much for this. Saved me the pain of trying to figure out what was wrong!

    By Sam on Wed, 4 March, 2009

  6. Woww.. Thank you very much. I have a same problem here. It's saved me hours to find the problem.

    By Frederick Lasmana on Thu, 5 March, 2009

  7. No problem both. Glad I saved someone some time!

    By Sarah on Thu, 5 March, 2009

  8. Thanks for the info.
    The original site mentions that this script is working with Jquery 1.3.1.x but i spent a good part of the day trying to see why the gallery is not working.

    I tried to email the guy but the contact page was very snide.
    contact [guess what goes in here]@lidnyl.com (or whatever lindly is spelled).
    well i cant guess what goes in there so if someone does guess it, mail it to the guy and tell him to fix his script up. it takes 10seconds and will help others who encounter this same issue.

    Thanks
    AlexD

    By AlexD on Mon, 9 March, 2009

  9. Hi Alex, I think Thickbox says it works with jQuery 1.1.3 not 1.3.1. It's a shame they don't make the one second fix! But I know how it feels to be busy and just not get the chance to make minor changes to what is essentially a free script.

    By Sarah on Thu, 12 March, 2009

  10. Thanks for posting this. It probably saved me my sanity and hours of work.

    By m00min on Fri, 13 March, 2009

  11. OMG thanks for posting !!! I can't believe that I spent hours trying to find the problem. You are a saviour !! thanks again.

    By Bob Johns on Sat, 28 March, 2009

  12. I have created a fork of the thickbox plugin to improve upon it and fix a number of its issues. The new version can be found on my web site.

    By Byrne Reese on Mon, 4 May, 2009

  13. Cheers for letting us know! :)

    By Sarah on Mon, 4 May, 2009

  14. Thanks for the tip; someone really should fork TB and track it with Google Code; I personally find some essential features lacking (autoresize, zoomin etc)… :(

    By rosamez on Sun, 10 May, 2009

  15. Finally I found the answer to the latest jquery and thickbox compatibility issue.

    I've been wondering if anyone would've found a fix. :)

    Thanks a bunch.

    By Danny Foo on Tue, 12 May, 2009

  16. Very awesome! Great find – and thanks for the help :)

    By Anthony on Wed, 13 May, 2009

  17. THANK YOU SOOOOOO MUCH !
    I was searching for 2 days the solution for this problem !!!!

    By Brigitte on Thu, 14 May, 2009

  18. Thank you thank you thank you
    Someone should realy point this out to the developer

    By Nik on Thu, 21 May, 2009

  19. Thanks mate, you just saved me a lot of troubles. Cheers! :)

    By wojtek on Fri, 22 May, 2009

  20. Gosh, who would have thought there to be an error in the thickbox code??

    After 3 hours of work, this was the fix we needed. This seems to apply to the latest version of jquery (1.3.2) and thickbox, and the bug occurs when displaying the images as a gallery (using the "rel" attribute).

    I've sent a quick email out to Cody Lindly, hope it helps.

    Thanks again

    By Tison on Tue, 26 May, 2009

  21. Hi all, glad to be of help although I'm just further reporting the fix after I found it! In regards to the thickbox developer, I think they're just too busy to maintain the plugin, which I can appreciate as I know how that feels!

    By Sarah on Tue, 26 May, 2009

  22. Many thanks. I had the same problem. It works now!

    By George on Wed, 27 May, 2009

  23. Brilliant ..! I hope your page show up on Google for a search for Thickbox…will save other like me a LOT of time. Thanks.

    By Alston on Fri, 29 May, 2009

  24. Thanks Sarah, that was driving me nuts!

    By Laura on Tue, 2 June, 2009

  25. yeah this caught me out too. Its the same story with older versions of the jquery inline validator. Thanks for sharing!

    By theodin on Thu, 4 June, 2009

  26. Thanks for this info. I use the compressed version of the thickbox. There is only one "@" in the compressed code, so I tried to remove it — and it works!

    Thank you!

    By Mike Basteln on Thu, 11 June, 2009

  27. You saved my day!
    Thanks a lot.

    By Exventri on Fri, 12 June, 2009

  28. I wished I had searched earlier – I never would have found that! Thanks a lot!!!

    By Elke on Fri, 12 June, 2009

  29. T H A N K S!!!

    By claudio on Fri, 26 June, 2009

  30. Thank you so so much! I've been struggling with this issue for some time now…

    By Jessica on Mon, 29 June, 2009

  31. Saved me hours of digging. Thanks.

    By Adam Rivera on Wed, 1 July, 2009

  32. This is so insanely USEFUL! I really, really, really appreciate your posting this solution! Thank you! Thank you! Thank you!!!! I'd keep typing, but my hands are getting tired!

    By Glen on Thu, 2 July, 2009

  33. Thanks.

    By Mark on Thu, 2 July, 2009

  34. THANK YOU!!!

    By stef on Mon, 13 July, 2009

  35. Thank You!!
    I'm Italian….. Grazie!!!

    By Elio on Tue, 21 July, 2009

  36. Damn I love you ! It took me hours and I didn't understand what was going on !
    Thanks !

    By Simon on Tue, 21 July, 2009

  37. Thanks Sarah!

    I've noticed that some months ago but doesn't have time to search why!

    You've jsut save our time, it's great!
    Good Job, really! :d

    By xkliber on Wed, 22 July, 2009

  38. I'm going to cry! I can't believe how difficult that was. Thank you for the simple solution.

    BTW, if you have the Compressed version, replace:

    {E=$("a[@1N="+g+"]"

    with

    {E=$("a[1N="+g+"]"

    Enjoy

    By Ashton Sanders on Fri, 24 July, 2009

  39. Thanks a lot, saved me some time!

    By Werner on Wed, 29 July, 2009

  40. Add me to the pile of thank yous :)

    By Jeff on Sun, 2 August, 2009

  41. It worked indeed, thank you!

    By Rem on Thu, 6 August, 2009

  42. I assume that people have tested the fix supplied by Sarah to work with IE?

    My IE thickbox links are still dead :(

    By yihfeng on Mon, 17 August, 2009

  43. Another BIG thank you!

    By Wim on Wed, 19 August, 2009

  44. @yihfeng – I checked my changes in Internet Explorer yes, so not sure why yours are not working. If you're still having problems can I suggest maybe taking the thickbox.js file from a WordPress install which has been updated and should work fine. You may just need to update the paths at the top of the file.

    To everyone else, you're welcome :)

    By Sarah on Fri, 21 August, 2009

  45. @Sarah:

    Thanks for the reply. I believe it wasn't working for me because I was in IE quirks mode:

    http://css-class.com/test/css/.....opera4.htm

    "A comment before the doctype triggers quirksmode in IE7"

    But it seems to work now :)

    Cheers.

    By yihfeng on Mon, 24 August, 2009

  46. thank you very muchhhh!!!!!!!!!!!! I spend so many hours trying to solve this!!!!!!!!!!!1 thank youuuuuuuuuuuuuuuuuu

    By Arnau on Tue, 25 August, 2009

  47. Thanks for the fix!

    If you're using the minified version, as I am, search for:
    E=$("a[@1N="+g+"]")
    and remove the @ to get
    E=$("a[1N="+g+"]")

    That solved the problem for me.

    [edit] Looks like somebody already posted this. Sorry for the duplicate :) [/edit]

    By BacH on Wed, 2 September, 2009

  48. Thanks for this!

    :)

    By bubba on Sun, 13 September, 2009

  49. Thickbox is designed by Cody Lindley. Cody is one of the developers of jQuery. I think giving him grief over a redundant '@' sign is a tad petty. I would much rather him spend his time continuing the development of jQuery or anything that makes a nasty script for the lazy, more palatable to all.

    By Bilbothecat on Mon, 14 September, 2009

  50. All I did was post up the fix for others to use if they hit the same problem. I've re-read my comments on this and whilst I did mention it was a quick fix to make, I've also pretty much defended Cody's position on not making the update as I know what it's like to be busy and not have the time to support free, non profit making work. I get plenty of hassle and demands to make fixes to the free WP plugins I've made which I'm never overly happy about as they're maintained in my free time for free.

    So I'm sorry if you feel that this post is purely here to give Cody grief but it isn't, it's here to help other people out and nothing more.

    By Sarah on Mon, 14 September, 2009

  51. Many thanks for this. I'd been abandoning thickbox for client projects until today, I ran into a client that didn't want to switch. That left me searching for a solution, that's how I found this great info. So, thanks for putting it out there!

    By jyoseph on Thu, 8 October, 2009

  52. Thanks sharing!

    By Micahe Shaw on Mon, 12 October, 2009

  53. Thank you so much … this was frustrating me endlessly.

    By AtReyU_101 on Mon, 26 October, 2009

  54. thanks very much. this is a great trick

    By Onur De?erli on Wed, 28 October, 2009

  55. Thanks so much for this! It solved a nasty production bug!

    By Shawn on Wed, 28 October, 2009

  56. Thanks this saved my couple hours?

    By Sarfaraz Soomro on Wed, 18 November, 2009

  57. thanks Sarah! much appreciated!

    By Elemental - South Africa Web Development on Tue, 15 December, 2009

  58. this is awesome! so glad i found your fix. THANK YOU SO MUCH for posting!!!!!!!!

    By laura on Sat, 9 January, 2010

  59. Thanks a lot. Half a day lost, but another half saved…

    By Molotok on Wed, 3 February, 2010

  60. Awesome! You helped me alot with this tiny change :3

    By Keenora on Mon, 22 February, 2010

  61. thank you so much! i've been looking everywhere for a solution! so so simple!

    By julie on Thu, 25 February, 2010

Trackbacks/Pingbacks

  1. Lightbox, Thickbox ?i Ultimate Fade-In Slideshow | MARGEO
  2. JQuery ThickBox Gallery Images Not Working | Website Designers and Webmasters
Leave a Comment

Please use your real name or nickname. Spam names will be changed.