I have tried following code, but it only positions dialogs left upper corner position to center, and that makes element to be aligned to right. How can I center dialog to real center which counts elements width, so that center line will cut dialog to 50% 50% halfs?
$('.selector').dialog({ position: 'center' });
Could not get IE9 to center the dialog.
Fixed it by adding this to the css:
Percent doesn't matter. Any small number worked.
According to the following discussion, the problem could be due to less IE compatibility in the newer jQuery versions, reverting back to 1.7.2 seems to resolve the problem, which only occurs in IE8. http://forum.jquery.com/topic/jquery-ui-dialog-positioning-not-working-in-ie-8
I'm getting best results to put jQuery dialog in the center of browser's window with:
There's probably more accurate way to position it with option "using" as described in the documentation at http://api.jqueryui.com/position/ but I'm in a hurry...
Are you running into this in IE only? If so, try adding this to the FIRST line of your page's HEAD tag:
I had though that all compatibility issues were fixed in later jQueries, but I ran into this one today.
I had a problem with this and I finally figured this out. Until today I was using a really old version of jQuery, version 1.8.2.
Everywhere where I had used
dialog
I had initialised it with the following position option:However, I found that removing
position: "center"
or replacing it with the correct syntax didn't do the trick, for example:Although the above is correct, I was also using
option
to set the position as center when I loaded the page, in the old way, like so:This was causing all of my dialog windows to stick to the top left of the view port.
I had to replace all instances of this with the correct new syntax below: