Wicket ModalWindow position

爷,独闯天下 提交于 2019-12-08 03:38:03

问题


I need to modify the position of the modal window before it gets displayed in the middle.

I have a ajaxbutton which will open the modal window. In the onClick method I tried something like...

target.appendJavaScript("$(\".wicket-modal\").css('width', 888+'px');");

or

target.appendJavaScript("$(\"[id^=_wicket_window]\").css('top', 100+'px');");

and some more variations of it...

It seems I can't manipulate the position of the ModalWindow before it gets displayed. But I can manipulate the position and size of an element INSIDE this modal window.

For example:

target.appendJavaScript("$(\".formdiv\").css('width', 888+'px');");

works. "formdiv" is a div in the modal window. It changes it's width, color and what I want.

But I need the position of the ModalWindow somewhere else at the first appearance. How can I do it?


回答1:


For an unknown reason to me the ModalWindow is opened with JavaScript timeout of 0 seconds. So you need to execute your custom JavaScript again with a timeout, e.g.:

target.appendJavaScript("setTimeout(function() {$('.wicket-modal').css('width', 888+'px');}, 10);");


来源:https://stackoverflow.com/questions/28811547/wicket-modalwindow-position

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!