problem with receipt of custom event

problem with receipt of custom event

Hello, in Jquery 1.6, I create a new window, and in that window I create a custom event, triggering it when the window closes

var evnt = jQuery.Event("previewWindowClose"); 
jQuery(window).bind("onunload", function() { 
            window.opener.jQuery(document).trigger(evnt, {"layerID":"' + layerID + '"});
        }); 

in the main window, I bind a handler function to the 'previewWindowClose' event.

jQuery(document).bind("previewWindowClose", function(evnt, evntData) { 
alert("handler called"); 
});

If I inspect the document element, I can see that the 'previewWindowClose' event has a handler bound to it on document.

If however I close the preview window, the handler I have bound the the previewWindowClose event is never called. I can't even figure out how to debug this. If I log events in Firebug I never see previewWindowClose being generated, but then again I am not sure that Firebug can see custom events.

Any suggestions? Thanks;

Garey Mills