diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js index dc2849155e0..031ce68eb41 100644 --- a/ui/jquery.ui.dialog.js +++ b/ui/jquery.ui.dialog.js @@ -693,13 +693,15 @@ $.extend( $.ui.dialog.overlay, { setTimeout(function() { // handle $(el).dialog().dialog('close') (see #4065) if ( $.ui.dialog.overlay.instances.length ) { - $( document ).bind( $.ui.dialog.overlay.events, function( event ) { - // stop events if the z-index of the target is < the z-index of the overlay - // we cannot return true when we don't want to cancel the event (#3523) - if ( $( event.target ).zIndex() < $.ui.dialog.overlay.maxZ ) { - return false; - } - }); + for( var i = 0; i < $.ui.dialog.overlay.instances.length; i++ ) { + $.ui.dialog.overlay.instances[ i ].bind( $.ui.dialog.overlay.events, function( event ) { + // stop events if the z-index of the target is < the z-index of the overlay + // we cannot return true when we don't want to cancel the event (#3523) + if ( $( event.target ).zIndex() < $.ui.dialog.overlay.maxZ ) { + return false; + } + }); + } } }, 1 );