From 649f105229b2a24adc21cba2d56cb05a59711ccb Mon Sep 17 00:00:00 2001 From: David Petersen Date: Wed, 23 Jan 2013 19:12:25 -0600 Subject: Dialog: Don't handle overlays on destory if there are not any. Fixed: #9004 - failed in _destroyOverlay when I destroy a modal dialog thau was never opened. Fixed: #9000 Dialog leaves broken event handler after close/destroy in certain cases --- ui/jquery.ui.dialog.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'ui/jquery.ui.dialog.js') diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js index ef5787ef6..bfe37235e 100644 --- a/ui/jquery.ui.dialog.js +++ b/ui/jquery.ui.dialog.js @@ -704,11 +704,15 @@ $.widget( "ui.dialog", { return; } - $.ui.dialog.overlayInstances--; - if ( !$.ui.dialog.overlayInstances ) { - this._off( this.document, "focusin" ); + if ( this.overlay ) { + $.ui.dialog.overlayInstances--; + + if ( !$.ui.dialog.overlayInstances ) { + this._off( this.document, "focusin" ); + } + this.overlay.remove(); + this.overlay = null; } - this.overlay.remove(); } }); -- cgit v1.2.3