I advise you not to associate FadeOut overlay with a closed private event.
This solution will work in all cases, for example, if you use the "Cancel" button, or if the dialog closes after doing something else due to other buttons:
$('#dialog').dialog({ autoOpen: true, modal: true, width: '100px', height: '100px', show: 'fade', hide: 'fade', open: function () { $('.ui-widget-overlay', this).hide().fadeIn(); }, beforeClose: function(event, ui){ // Wait for the overlay to be faded out to try to close it again if($('.ui-widget-overlay').is(":visible")){ $('.ui-widget-overlay').fadeOut(function(){ $('.ui-widget-overlay').hide(); $('.ui-icon-closethick').trigger('click'); }); return false; // Avoid closing } } });
source share