Today I ran into problems with wickets ModalWindow. I have got a modal dialog with a list and a form in it. The user can add a row to this list with the form. Problem was that the size of the modal window stayed as it was although the list was growing and growing. Nasty scroll bars appeared around my modal dialog. So I’d like to make the dialog to “auto resize” on each post.
My solution was simple. I just added this line of code in the onsubmit handler of the ajax button:
[java] // in the onsubmit handler of the ajax buttontarget.appendJavaScript("window.parent.Wicket.Window.current.autoSizeWindow();");
//[/java]
It’s like magic. Now the modal dialog always has the proper size 😉
(Tested with wicket version 1.5.5)
EDIT1: also have a look at Williams note below (the first comment)
EDIT2: also consider Nikkes solution!
Comments 5
Very good information!. Still its important to note this will only work if your Modal has a Component that is a Panel, as if you are using a Panel Creator it will refize having a minimum size (nothing will be seen)
William, thank you very much for your note. I will append it to my article.
Thanks Martin!
Here is tiny modification that uses get() function in modal.js to get the current window instead of direct use of Wicket.Window.current that seems to work as well.
target.appendJavaScript(“Wicket.Window.get().autoSizeWindow();”);
Hello Nikke, thank you for your consideration! Edited my article.
Hey,
Thanks for your post.
I have a modal which vertical size is greater than the visible page, when i try to scroll, it scrolls down the page behind the modal page, got any ideas?