PDA

View Full Version : Quick Issue with Lightbox/Javascript!




Littleodie914
Jul 10, 2007, 10:05 PM
Hey guys, I'm having a really small (but really big) problem in which lightbox will work when called in normal HTML like:

<a href='sky.jpg' rel='lightbox'>Go</a>

But will simply load the file in the browser window when calling it like:

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:

document.getElementById("right").innerHTML = "<a href=\'sky.jpg\' rel=lightbox>Go</a>"
initLightbox();



Littleodie914
Jul 10, 2007, 11:46 PM
Ah, scratch that... More issues.

I'm having a problem in Firefox, if anybody wants to test it out:

Head here, then click Screenshots (http://www.craigotis.com/ajax/)

stadidas
Jul 11, 2007, 06:19 AM
Looks great in Safari 3. Your app looks wicked too.

Littleodie914
Jul 11, 2007, 07:39 AM
Looks great in Safari 3. Your app looks wicked too.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?

stadidas
Jul 11, 2007, 07:53 AM
My flat mate is a web developer, I'll ask him if he has any ideas when he gets home.

Littleodie914
Jul 11, 2007, 08:17 AM
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:

Littleodie914
Jul 11, 2007, 09:28 AM
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?

Littleodie914
Jul 11, 2007, 06:34 PM
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. :)