I am using this method with jQuery 1.9.1 and jQuery UI 1.9.2. I am using this to keep the dialog within the view port if the user resizes their browser window smaller than the current size of the dialog. I also have dialogs in which I load additional content to the dialog after it is initiated which at times is longer than the window size. My problem is that once you set the size using the dialog option, the user can no longer manually resize the dialog using the handles. Any solution to this? Example function below:
function positionDialog(){var myDialog = $("div.myDialogContainer:visible"); var availableHeight = $("body").height() - 20; var availableWidth = $("body").width() - 20; var dialogHeight = myDialog.parent().height(); var dialogWidth = myDialog.parent().width(); if(dialogHeight<=availableHeight){myDialog.dialog("option", "height", "auto" );}else{myDialog.dialog("option", "height", availableHeight );}if(dialogWidth>=availableWidth){myDialog.dialog("option", "width", availableWidth );}myDialog.dialog("option", "position", "center");}