Skip to content
This repository
Browse code

[popup] Use new ._on() binding method to attach handlers such that th…

…ey are removed upon _destroy()
  • Loading branch information...
commit c21100aa9e232fd923e85f976a0f00225797c098 1 parent 225be4a
Gabriel "_|Nix|_" Schulhof authored August 02, 2012

Showing 1 changed file with 4 additions and 20 deletions. Show diff stats Hide diff stats

  1. 24  js/widgets/popup.js
24  js/widgets/popup.js
@@ -159,16 +159,6 @@ define( [ "jquery",
159 159
 				_tolerance: null,
160 160
 				_resizeData: null,
161 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  
-				]
172 162
 			});
173 163
 
174 164
 			$.each( this.options, function( key, value ) {
@@ -179,9 +169,10 @@ define( [ "jquery",
179 169
 			});
180 170
 
181 171
 			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"
185 176
 			});
186 177
 		},
187 178
 
@@ -579,13 +570,6 @@ define( [ "jquery",
579 570
 			this._ui.screen.remove();
580 571
 			this._ui.container.remove();
581 572
 			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  
-			});
589 573
 		},
590 574
 
591 575
 		open: function( options ) {

0 notes on commit c21100a

Please sign in to comment.
Something went wrong with that request. Please try again.