1

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?

DaUser
  • 357
  • 3
  • 5
  • 19
  • Have you tried `modal.setInitialWidth(888);` ? – papkass Mar 03 '15 at 07:32
  • I set an initial width and height but as you can read I need a new (start) position and not the default center. The jQuery code with width was just an example of what is also not possible. – DaUser Mar 03 '15 at 09:17

1 Answers1

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);");
martin-g
  • 17,243
  • 2
  • 23
  • 35