Can't close modal panel inside modal page.
------------------------------------------

                 Key: WICKET-2053
                 URL: https://issues.apache.org/jira/browse/WICKET-2053
             Project: Wicket
          Issue Type: Bug
          Components: wicket-extensions
    Affects Versions: 1.4-RC1, 1.3.5
            Reporter: Yosi


I have ModalWindow showing a page containing anothor (child) ModalWindow 
showing a panel.

When trying to close the inner panel ModalWindow wicket is trying to close the 
parent ModalWindow (page).

I found the error in modal.js:
---------------------------------------------------

Wicket.Window.close = function() {
        
        var win;
        try {           
                win = window.parent.Wicket.Window;
        } catch (ignore) {              
        }
        
        if (typeof(win) != "undefined" && typeof(win.current) != "undefined") {
                // we can't call close directly, because it will delete our 
window,
                // so we will schedule it as timeout for parent's window
                window.parent.setTimeout(function() {
                        win.current.close();                    
                }, 0);
        }
}



the following code seem to fix it:
---------------------------------------------------

Wicket.Window.close = function() {
        var win;
        try {
                win = window.parent.Wicket.Window;
        } catch (ignore) {
        }

        if (typeof(win) == "undefined" || typeof(win.current) == "undefined") {
                try {
                        win = window.Wicket.Window;
                } catch (ignore) {
                }
        }

        if (typeof(win) != "undefined" && typeof(win.current) != "undefined") {
                if (win.current.content.tagName.toLowerCase() == 'iframe') {
                        var innerWin = 
win.current.content.contentWindow.Wicket.Window;
                        if (innerWin && innerWin.current) {
                                win = innerWin;
                        }
                }

                var close = function(w) {
                        w.setTimeout(function() {
                                win.current.close();
                        }, 0);
                };
                try {
                        close(window.parent);
                } catch (ignore) {
                        close(window);
                }
        }
};

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to