diff --git a/ui/jquery.ui.dialog.js b/ui/jquery.ui.dialog.js index 77392cb199..472d686a2c 100644 --- a/ui/jquery.ui.dialog.js +++ b/ui/jquery.ui.dialog.js @@ -665,17 +665,19 @@ $.widget("ui.dialog", { // prevent use of anchors and inputs // we use a setTimeout in case the overlay is created from an // event that we're going to be cancelling (see #2804) - setTimeout(function() { + this._delay(function() { // handle $(el).dialog().dialog('close') (see #4065) if ( $.ui.dialog.overlayInstances ) { - $( document ).bind( "focusin.dialog-overlay", function( event ) { - if ( !$( event.target ).closest( ".ui-dialog").length ) { - event.preventDefault(); - $( ".ui-dialog:visible:last .ui-dialog-content" ).data( "ui-dialog" )._focusTabbable(); + this._on( this.document, { + focusin: function( event ) { + if ( !$( event.target ).closest( ".ui-dialog").length ) { + event.preventDefault(); + $( ".ui-dialog:visible:last .ui-dialog-content" ).data( "ui-dialog" )._focusTabbable(); + } } }); } - }, 1 ); + }); } var $el = this.overlay = $( "