Lightbox can't run with Smooth Scrolling jQuery script I have added.

Discussion in 'Web Design and Development' started by Diggity Dang, Aug 16, 2009.

  1. Diggity Dang macrumors newbie

    Dec 25, 2007
    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>

    I appreciate anyone's help on the matter! Thanks so much!
  2. angelwatt Moderator emeritus


    Aug 16, 2005
    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.
  3. Diggity Dang thread starter macrumors newbie

    Dec 25, 2007
    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!
  4. angelwatt Moderator emeritus


    Aug 16, 2005
    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.
  5. Diggity Dang thread starter macrumors newbie

    Dec 25, 2007
    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!
  6. Ride9650 macrumors 6502

    Jun 29, 2007
    Have you tried using thickbox instead of lightbox?

    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.

Share This Page