[thelist] [javascript] Window.onload > YUI vs. Prototype

Paul Bennett Paul.Bennett at wcc.govt.nz
Sun Apr 6 22:47:11 CDT 2008


Weird question of the day.

We use one main javascript file which has some utility functions and attaches event handlers etc. Occasionally we also use lightbox. This is all fine and dandy if the lightbox files are included *after* the common js as I've told people and even created simple GUI's to semi-automate the creation of new pages with all bits in the right place.

Well, someone has been clever and done some update work, placing the lightbox includes *above* the common js includes on about 100 pages. The consequence is that lightbox no longer works on these pages, as it seems when window.onload is called the 2nd time it wipes out previous event handlers.(?)

Said person is not here today and I'd rather not trawl through the pages and make 100 manual code changes, so what I'm trying to do is reload lightbox from the common js file like so:

// see if the Lightbox class has been parsed
if(typeof Lightbox == 'function'){
                // instantiate lightbox (again)
                myLightbox = new Lightbox();

This *does* load lightbox again (I've placed some alerts in lightbox.js to check, it *does* find anchors with the right rel attribute, but it doesn't attach event handlers to the anchors. No js errors (firebug is silent) - it just *doesn't work*.

Does anyone have any ideas to point me in the right direction?


More information about the thelist mailing list