views:

78

answers:

1

In the django function showRelatedObjectLookupPopup, I'd like to bind a function to a button in the newly popped up window, but I don't know how to refer to the new window. Here is what I have tried:

function showRelatedObjectLookupPopup(triggeringLink) {
// other function stuff omitted
    var name = triggeringLink.id.replace(/^lookup_/, '');
    name = id_to_windowname(name);
    var win = window.open(href, name, 500, 700, resizable=yes, scrollbars=yes');

    win.onload = function () {
         $(document).ready(function() {
               $("input.default").hover(function () {alert('hovered')})})};
    win.focus();
    return false;
}

But this binds to the button in the original window.

+1  A: 

I think you are referring to the current window's document when you use

win.onload = function() { $(document).ready(...

try this:

win.onload = function() { $(win.document).ready(...

and likewise, give a context to your input selector:

 $("input.default", win.document).hover(...
Jeff Meatball Yang
That's it. Thanks a lot.
Mitch