Skip to content

Commit 34ec236

Browse files
author
Gabriel Schulhof
committed
[popup] Use new ._on() binding method to attach handlers such that they are removed upon _destroy()
1 parent 6ec2690 commit 34ec236

File tree

1 file changed

+5
-21
lines changed

1 file changed

+5
-21
lines changed

js/widgets/popup.js

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -158,17 +158,7 @@ define( [ "jquery",
158158
_isOpen: false,
159159
_tolerance: null,
160160
_resizeData: null,
161-
_orientationchangeInProgress: false,
162-
_globalHandlers: [
163-
{
164-
src: $( window ),
165-
handler: {
166-
orientationchange: $.proxy( this, "_handleWindowOrientationchange" ),
167-
resize: $.proxy( this, "_handleWindowResize" ),
168-
keyup: $.proxy( this, "_handleWindowKeyUp" )
169-
}
170-
}
171-
]
161+
_orientationchangeInProgress: false
172162
});
173163

174164
$.each( this.options, function( key, value ) {
@@ -179,9 +169,10 @@ define( [ "jquery",
179169
});
180170

181171
ui.screen.bind( "vclick", $.proxy( this, "_eatEventAndClose" ) );
182-
183-
$.each( this._globalHandlers, function( idx, value ) {
184-
value.src.bind( value.handler );
172+
this._on( window, {
173+
orientationChange: "_handleWindowOrientationChange",
174+
resize: "_handleWindowResize",
175+
keyup: "_handleWindowKeyUp"
185176
});
186177
},
187178

@@ -579,13 +570,6 @@ define( [ "jquery",
579570
this._ui.screen.remove();
580571
this._ui.container.remove();
581572
this._ui.placeholder.remove();
582-
583-
// Unbind handlers that were bound to elements outside this.element (the window, in this case)
584-
$.each( this._globalHandlers, function( idx, oneSrc ) {
585-
$.each( oneSrc.handler, function( eventType, handler ) {
586-
oneSrc.src.unbind( eventType, handler );
587-
});
588-
});
589573
},
590574

591575
open: function( options ) {

0 commit comments

Comments
 (0)