Quick Issue with Lightbox/Javascript!

Discussion in 'Mac Programming' started by Littleodie914, Jul 10, 2007.

  1. macrumors 68000

    Littleodie914

    Joined:
    Jun 9, 2004
    Location:
    Rochester, NY
    #1
    Hey guys, I'm having a really small (but really big) problem in which lightbox will work when called in normal HTML like:

    Code:
    <a href='sky.jpg' rel='lightbox'>Go</a>
    But will simply load the file in the browser window when calling it like:

    Code:
    document.getElementById("right").innerHTML = "<a href=\'sky.jpg\' rel=\'lightbox\'>Go</a>"
    I'm pretty sure there're no syntactical errors, as the page loads and maneuvers fine, but the "lightbox" part just doesn't work. :confused:


    Edit: Solved my own question. Turns out you have to reinitialize lightbox after dynamically changing the HTML. Here's what works now:

    Code:
    document.getElementById("right").innerHTML = "<a href=\'sky.jpg\' rel=lightbox>Go</a>"
    initLightbox();
     
  2. thread starter macrumors 68000

    Littleodie914

    Joined:
    Jun 9, 2004
    Location:
    Rochester, NY
    #2
  3. macrumors regular

    Joined:
    Feb 27, 2006
    Location:
    Kent, United Kingdom
    #3
    Looks great in Safari 3. Your app looks wicked too.
     
  4. thread starter macrumors 68000

    Littleodie914

    Joined:
    Jun 9, 2004
    Location:
    Rochester, NY
    #4
    Thanks a lot :) I've got a few changes to make both with the site and the app, me and my friend are just starting some real-world testing, so I wouldn't tell all your friends about it just yet. :)

    And yea, that's what's weird. In Safari, it works great. In Firefox, (I've got 2.0.0.4, the newest for Mac.) The screenshot windows in lightbox look atrocious. :confused:Any ideas?
     
  5. macrumors regular

    Joined:
    Feb 27, 2006
    Location:
    Kent, United Kingdom
    #5
    My flat mate is a web developer, I'll ask him if he has any ideas when he gets home.
     
  6. thread starter macrumors 68000

    Littleodie914

    Joined:
    Jun 9, 2004
    Location:
    Rochester, NY
    #6
    Hmm, just switched over to Bootcamp, and the same problem occurs in Firefox for Windows. This seems to be my problem alone... Anyone seen this before? :confused:
     
  7. thread starter macrumors 68000

    Littleodie914

    Joined:
    Jun 9, 2004
    Location:
    Rochester, NY
    #7
    Now, if you open the lightbox image on the index.html page (coded in HTML) THEN load the screenshots page and try any of the links that were dynamically changed, they all load just fine.

    Why is it that opening that first image causes all the rest of them to work okay?
     
  8. thread starter macrumors 68000

    Littleodie914

    Joined:
    Jun 9, 2004
    Location:
    Rochester, NY
    #8
    I still can't figure it out... I've been working on it most of the day. :(

    Here's a screenshot I took so you can see exactly what the problem is:

    Edit: Problem finally fixed! I snuck around on lightbox's site and downgraded from the latest 2.03.3 release to 2.02, and it fixed the problem entirely. Sorry for all the in-order posts. :)
     

    Attached Files:

Share This Page