@@ -665,17 +665,19 @@ $.widget("ui.dialog", {
665
665
// prevent use of anchors and inputs
666
666
// we use a setTimeout in case the overlay is created from an
667
667
// event that we're going to be cancelling (see #2804)
668
- setTimeout ( function ( ) {
668
+ this . _delay ( function ( ) {
669
669
// handle $(el).dialog().dialog('close') (see #4065)
670
670
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
+ }
675
677
}
676
678
} ) ;
677
679
}
678
- } , 1 ) ;
680
+ } ) ;
679
681
}
680
682
681
683
var $el = this . overlay = $ ( "<div>" ) . addClass ( "ui-widget-overlay ui-front" ) ;
@@ -692,7 +694,7 @@ $.widget("ui.dialog", {
692
694
}
693
695
$ . ui . dialog . overlayInstances -= 1 ;
694
696
if ( $ . ui . dialog . overlayInstances === 0 ) {
695
- $ ( [ document , window ] ) . unbind ( ".dialog-overlay " ) ;
697
+ this . _off ( this . document , "focusin " ) ;
696
698
}
697
699
this . overlay . remove ( ) ;
698
700
}
0 commit comments