Thursday 23 June 2011

Turning off the CLOSE button in a jquery dialog

Here is a wee tip if your jquery and jquery UI elements in your apps. There may be an occasion when you want to use a jquery dialog and turn off the user's ability to close the dialog using ESC or the X in the top left of the dialog.

The easiest way to do this is thus

$("#xlogon").dialog(
{ modal: true,
closeOnEscape: false,
focus: function(event, ui) {
        $(".ui-dialog-titlebar-close").hide()
}});

the closeOnEscape is a supplied method and does what it says it does and the FOCUS event function hides the X in the top right of the dialog.

Disqus for Domi-No-Yes-Maybe