views:

271

answers:

5

I just moved my javascript over to jQuery for the simple AJAX functions. However I'm trying to use a lightbox plugin with jQuery since I want to keep the same functionality but don't want to include 10 different libraries. If i remove the jquery include and keep lightbox, it works great if i put it back it breaks, it just brings up the full size image instead of the box, neither chrome or firefox's console complains about anything, it just goes straight to the image I tried 5 different lightbox clones/plugins for jQuery but they all gave me the same behavior, which leads me to think there's something i'm missing

right now my headers look like this (double checked, they're all there):

<script type='text/javascript' src='js/jquery.js'></script>
<script type='text/javascript' src='js/thickbox.js'></script>
<link rel='stylesheet' type='text/css' href='css/thickbox.css' />

and my gallery (php):

foreach(...){
echo "<a href=\"$path\" class='thickbox' rel='$folder'><img border=none src=\"$thumb\" /></a>&nbsp;\n" ;
}

for the background, the images in the foreach are loaded from an ajax call, but this was never a problem with lightbox, it shouldn't be because all the html is there anyway

+3  A: 

This is usually because other libraries (not jQuery) also try to use the dollar sign variable name.

There's a setting in jQuery to turn on compatibility mode which will force you to use jQuery() instead of $() to make jQuery calls.

Jasconius
Yes, I replaced my $ with jquery for the ajax and it works...but only in chrome :(
Blackbird57
A: 

Just a thought... doesn't LightBox attempt to include it's own copy of jQuery or something similar? IIRC, that might be the cause of your issues...

ZombieSheep
The original Lightbox is based on prototype, the plugin i'm using uses jquery. I tried removing my own jquery and leaving it up to the plugin, doesn't work, and it breaks my ajax
Blackbird57
A: 

Try looking at Shadowbox. It has the same kind of effect but has not had issues with JQuery for me. They also have a very similar set up and are pretty easy to switch between.

jmein
Just tried that one, and slimbox too. None of them worked, I think there's a problem when the thumbs load from ajax, because i ran a small test without ajax (with jquery) and the modal window worked
Blackbird57
+2  A: 

You could also use the jQuery Lightbox Plugin

Natim
I will advocate this, the jQuery Lightbox Plugin is superior in a couple of ways to the original.
Jasconius
That's the one I'm going with. I found the solution, for future reference. The javascript code: $('#yourdiv a').lightBox()wasn't being included because my content was fetched through AJAXThe way to solve this is to add it in the $(document).ready() and make sure to include the relevant js files in the page, even in the content retrieved by AJAX if it's a new page
Blackbird57
A: 

You can find different ways to resolve conflict here: Using_jQuery_with_Other_Libraries

greatromul