Skip to content
This repository
Browse code

Merge pull request #3008 from eddiemonge/live-delegate

Change .live() to .delegate()
  • Loading branch information...
commit 3542c9c0b1e8ed3843fc2a4f5acf37ed705e5a6b 2 parents a0ec2eb + c367c83
Ghislain Seguin authored November 17, 2011
2  js/jquery.mobile.dialog.js
@@ -66,7 +66,7 @@ $.widget( "mobile.dialog", $.mobile.widget, {
66 66
 });
67 67
 
68 68
 //auto self-init widgets
69  
-$( $.mobile.dialog.prototype.options.initSelector ).live( "pagecreate", function(){
  69
+$( document ).delegate( $.mobile.dialog.prototype.options.initSelector, "pagecreate", function(){
70 70
 	$( this ).dialog();
71 71
 });
72 72
 
10  js/jquery.mobile.fixHeaderFooter.js
@@ -150,9 +150,7 @@ $.mobile.fixedToolbars = (function() {
150 150
 
151 151
 	// 1. Before page is shown, check for duplicate footer
152 152
 	// 2. After page is shown, append footer to new page
153  
-	$( ".ui-page" )
154  
-		.live( "pagebeforeshow", function( event, ui ) {
155  
-
  153
+	$( document ).delegate( ".ui-page", "pagebeforeshow", function( event, ui ) {
156 154
 			var page = $( event.target ),
157 155
 				footer = page.find( ":jqmData(role='footer')" ),
158 156
 				id = footer.data( "id" ),
@@ -165,12 +163,10 @@ $.mobile.fixedToolbars = (function() {
165 163
 				setTop( stickyFooter.removeClass( "fade in out" ).appendTo( $.mobile.pageContainer ) );
166 164
 			}
167 165
 		})
168  
-		.live( "pageshow", function( event, ui ) {
169  
-
  166
+		.delegate( ".ui-page", "pageshow", function( event, ui ) {
170 167
 			var $this = $( this );
171 168
 
172 169
 			if ( stickyFooter && stickyFooter.length ) {
173  
-
174 170
 				setTimeout(function() {
175 171
 					setTop( stickyFooter.appendTo( $this ).addClass( "fade" ) );
176 172
 					stickyFooter = null;
@@ -181,7 +177,7 @@ $.mobile.fixedToolbars = (function() {
181 177
 		});
182 178
 
183 179
 	// When a collapsiable is hidden or shown we need to trigger the fixed toolbar to reposition itself (#1635)
184  
-	$( ".ui-collapsible-contain" ).live( "collapse expand", showEventCallback );
  180
+	$( document ).delegate( ".ui-collapsible-contain", "collapse expand", showEventCallback );
185 181
 
186 182
 	// element.getBoundingClientRect() is broken in iOS 3.2.1 on the iPad. The
187 183
 	// coordinates inside of the rect it returns don't have the page scroll position
2  js/jquery.mobile.forms.select.custom.js
@@ -483,7 +483,7 @@
483 483
 		});
484 484
 	};
485 485
 
486  
-	$( "select" ).live( "selectmenubeforecreate", function(){
  486
+	$( document ).delegate( "select", "selectmenubeforecreate", function(){
487 487
 		var selectmenuWidget = $( this ).data( "selectmenu" );
488 488
 
489 489
 		if( !selectmenuWidget.options.nativeMenu ){
2  js/jquery.mobile.listview.filter.js
@@ -11,7 +11,7 @@ $.mobile.listview.prototype.options.filterCallback = function( text, searchValue
11 11
 	return text.toLowerCase().indexOf( searchValue ) === -1;
12 12
 };
13 13
 
14  
-$( ":jqmData(role='listview')" ).live( "listviewcreate", function() {
  14
+$( document ).delegate( ":jqmData(role='listview')", "listviewcreate", function() {
15 15
 
16 16
 	var list = $( this ),
17 17
 		listview = list.data( "listview" );
6  js/jquery.mobile.navigation.js
@@ -1094,7 +1094,7 @@
1094 1094
 
1095 1095
 		// Kill the keyboard.
1096 1096
 		// XXX_jblas: We need to stop crawling the entire document to kill focus. Instead,
1097  
-		//            we should be tracking focus with a live() handler so we already have
  1097
+		//            we should be tracking focus with a delegate() handler so we already have
1098 1098
 		//            the element in hand at this point.
1099 1099
 		// Wrap this in a try/catch block since IE9 throw "Unspecified error" if document.activeElement
1100 1100
 		// is undefined when we are in an IFrame.
@@ -1226,7 +1226,7 @@
1226 1226
 	$.mobile._registerInternalEvents = function(){
1227 1227
 
1228 1228
 		//bind to form submit events, handle with Ajax
1229  
-		$( "form" ).live('submit', function( event ) {
  1229
+		$( document ).delegate( "form", "submit", function( event ) {
1230 1230
 			var $this = $( this );
1231 1231
 			if( !$.mobile.ajaxEnabled ||
1232 1232
 				$this.is( ":jqmData(ajax='false')" ) ) {
@@ -1393,7 +1393,7 @@
1393 1393
 		});
1394 1394
 
1395 1395
 		//prefetch pages when anchors with data-prefetch are encountered
1396  
-		$( ".ui-page" ).live( "pageshow.prefetch", function() {
  1396
+		$( document ).delegate( ".ui-page", "pageshow.prefetch", function() {
1397 1397
 			var urls = [];
1398 1398
 			$( this ).find( "a:jqmData(prefetch)" ).each(function(){
1399 1399
 				var $link = $(this),
2  js/jquery.mobile.page.sections.js
@@ -11,7 +11,7 @@ $.mobile.page.prototype.options.headerTheme  = "a";
11 11
 $.mobile.page.prototype.options.footerTheme  = "a";
12 12
 $.mobile.page.prototype.options.contentTheme = null;
13 13
 
14  
-$( ":jqmData(role='page'), :jqmData(role='dialog')" ).live( "pagecreate", function( e ) {
  14
+$( document ).delegate( ":jqmData(role='page'), :jqmData(role='dialog')", "pagecreate", function( e ) {
15 15
 	
16 16
 	var $page = $( this ),
17 17
 		o = $page.data( "page" ).options,

0 notes on commit 3542c9c

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