PDA

View Full Version : Lightbox can't run with Smooth Scrolling jQuery script I have added.




Diggity Dang
Aug 16, 2009, 10:03 AM
Hey All,

I have a question regarding Lightbox and another jQuery script (smooth scrolling) I'm trying to run on the same page. I have installed Lightbox v2.04 successfully on my page (it has not been published online yet). However, I am trying to add jQuery's smooth scrolling to my page as well. I did both of these successfully on their own, but when the two are put together, Lightbox crashes when I installed smooth scrolling. When I tried removing the smooth scrolling, Lightbox worked again. Basically, the scripts appear to be crashing into each other and only one supercedes (smooth scrolling). These are the two scripts within my head tag:

This is the one for Lightbox:

<script type="text/javascript" src="lightbox2.04/js/prototype.js"></script>
<script type="text/javascript" src="lightbox2.04/js/scriptaculous.js?load=effects,builder"></script>
<script type="text/javascript" src="lightbox2.04/js/lightbox.js"></script>

And this is the one for Smooth Scrolling (where Lightbox does NOT crash if I remove the first two lines, but obviously smooth scrolling no longer works again - not sure if that helps at all).

<script type="text/javascript" src="js_smooth_scrolling/jquery-1.3.2.js"></script>
<script type="text/javascript" src="js_smooth_scrolling/jquery.smoothanchors2.js"></script>
<script>
$(document).ready(function(){
$.smoothAnchors("normal");
});
</script>-->

I appreciate anyone's help on the matter! Thanks so much!



angelwatt
Aug 16, 2009, 10:15 AM
What do you mean by crash? Are there errors? It's likely an issue of the scripts using the same name on a function or variable that is overwriting the other. It's a problem with some of the frameworks.

Diggity Dang
Aug 16, 2009, 02:37 PM
What do you mean by crash? Are there errors? It's likely an issue of the scripts using the same name on a function or variable that is overwriting the other. It's a problem with some of the frameworks.

Thanks for the reply. When I say "crash", what I mean is that the smooth scrolling turns the lightbox off. So, if I click on the thumbnails I have set up, the larger image just opens in a separate window, not in lightbox.

I'm a bit of a newbie to all of this - how do I find duplicate names on the scripts or correct the variable that is overwriting?

Thanks again!

angelwatt
Aug 16, 2009, 05:56 PM
jQuery has a compatibility mode (http://docs.jquery.com/Using_jQuery_with_Other_Libraries) that you can try out. I don't use any JavaScript frameworks so can't give much help. Tracking down duplicated names doesn't tell you how to fix it as changing the names often causes cascading issues.

Diggity Dang
Aug 18, 2009, 09:04 PM
jQuery has a compatibility mode (http://docs.jquery.com/Using_jQuery_with_Other_Libraries) that you can try out. I don't use any JavaScript frameworks so can't give much help. Tracking down duplicated names doesn't tell you how to fix it as changing the names often causes cascading issues.

Hey Angelwatt,

I appreciate your response. I managed to download another jQuery - Lightbox which worked better... this in turn spawned a host of other issues, including listing NaN as the page number, but it's now compatible with the smooth scrolling. I have removed the page numbers for now.

Thanks again though!

Ride9650
Aug 25, 2009, 11:36 AM
Have you tried using thickbox instead of lightbox?
http://jquery.com/demo/thickbox/

As you have no doubt read, the Prototype framework and jquery don't work too well together.

I think its better than Lightbox in alot of respects, cause you can pretty much dump just about anything into it aside from photos, though admitingly, its probably not as pretty.