View Full Version : Milkbox and javascripts innerHTML issue

07-27-2010, 04:56 AM
Hi All,

I have been fighting with an issue with milkbox for the past 6 hours, at this point I am just plain frustrated. What I am trying to do is implement Milkbox. Integrating it is not the problem since I have done this plenty of times. When you first come to the page and click the first thumbnail image it works fine. however it only works when you first come to the page and then when you click the next portfolio item and then click the thumb nail image that is displayed it does not show the image in lightbox, it just shows it in a blank page. I am setting the new image using the .innerHTML method. I am doing this because I am changing the div contents to something that looks along the lines of

<a href="portfolio/tiresfortreatment.jpg" rel="milkbox" title="Tires for Treatment"><img src="slices/portfolio/thumbs/tires-for-treatment.png" alt="Tires for Treatment" /></a>

I read that innerHTML removes event listeners from html elements. So then I tried to call the milkbox constructor directly by changing the text of my .innerHTML property to directly call the constructor of milkbox on click like this:

<a href="portfolio/tiresfortreatment.jpg" rel="milkbox" title="Tires for Treatment" onclick="Milkbox.initialize()"><img src="slices/portfolio/thumbs/tires-for-treatment.png" alt="Tires for Treatment" /></a>

To get a clear understanding of what's going on the page can be viewed at :


The custom javascript file (part of the issue) is located at:


The milkbox class can be viewed at:


Any help would be more than appreciated.

Thanks for your time,