Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Diggity Dang

macrumors newbie
Original poster
Dec 25, 2007
26
0
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!
 
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.
 
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!
 
jQuery has a compatibility mode 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.
 
jQuery has a compatibility mode 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!
 
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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.