Sometimes the default and automatic center positioning of a jQuery dialog upon opening does not work.
jQuery("#dialogDiv").dialog({ height: 'auto', modal: true, width: 400, autoOpen: false, position: 'center' });
I found the following code works to position the jQuery UI dialog in the center of the screen:
var x = document.body.clientWidth / 2; var y = document.body.clientHeight / 2; var dlg = jQuery("#dialogDiv"); dlg.dialog('option', 'position', [x, y]); //dlg.dialog('option', 'position', 'center'); dlg.dialog('open');
1 comment:
I already tried but it is not working.
Post a Comment