@@ -665,17 +665,19 @@ $.widget("ui.dialog", {
665665 // prevent use of anchors and inputs
666666 // we use a setTimeout in case the overlay is created from an
667667 // event that we're going to be cancelling (see #2804)
668- setTimeout ( function ( ) {
668+ this . _delay ( function ( ) {
669669 // handle $(el).dialog().dialog('close') (see #4065)
670670 if ( $ . ui . dialog . overlayInstances ) {
671- $ ( document ) . bind ( "focusin.dialog-overlay" , function ( event ) {
672- if ( ! $ ( event . target ) . closest ( ".ui-dialog" ) . length ) {
673- event . preventDefault ( ) ;
674- $ ( ".ui-dialog:visible:last .ui-dialog-content" ) . data ( "ui-dialog" ) . _focusTabbable ( ) ;
671+ this . _on ( this . document , {
672+ focusin : function ( event ) {
673+ if ( ! $ ( event . target ) . closest ( ".ui-dialog" ) . length ) {
674+ event . preventDefault ( ) ;
675+ $ ( ".ui-dialog:visible:last .ui-dialog-content" ) . data ( "ui-dialog" ) . _focusTabbable ( ) ;
676+ }
675677 }
676678 } ) ;
677679 }
678- } , 1 ) ;
680+ } ) ;
679681 }
680682
681683 var $el = this . overlay = $ ( "<div>" ) . addClass ( "ui-widget-overlay ui-front" ) ;
@@ -692,7 +694,7 @@ $.widget("ui.dialog", {
692694 }
693695 $ . ui . dialog . overlayInstances -= 1 ;
694696 if ( $ . ui . dialog . overlayInstances === 0 ) {
695- $ ( [ document , window ] ) . unbind ( ".dialog-overlay " ) ;
697+ this . _off ( this . document , "focusin " ) ;
696698 }
697699 this . overlay . remove ( ) ;
698700 }
0 commit comments