Browse files

Removed all instances of .live() and .die() in docs and test suite

  • Loading branch information...
1 parent 212e71e commit f22f74aae4fff766b321fc34244ff4acd61ddfa2 @JangoSteve JangoSteve committed Jan 18, 2013
Showing with 23 additions and 21 deletions.
  1. +2 −2 src/rails.js
  2. +16 −16 test/public/test/call-remote-callbacks.js
  3. +5 −3 test/public/test/data-disable.js
View
4 src/rails.js
@@ -15,7 +15,7 @@
* The `ajax:aborted:file` event allows you to bind your own handler to process the form submission however you wish.
*
* Ex:
- * $('form').live('ajax:aborted:file', function(event, elements){
+ * $('form').bind('ajax:aborted:file', function(event, elements){
* // Implement own remote file-transfer handler here for non-blank file inputs passed in `elements`.
* // Returning false in this handler tells rails.js to disallow standard form submission
* return false;
@@ -38,7 +38,7 @@
* get fired in Opera. This event is what causes other browsers to exhibit the same submit-aborting behavior.
*
* Ex:
- * $('form').live('ajax:aborted:required', function(event, elements){
+ * $('form').bind('ajax:aborted:required', function(event, elements){
* // Returning false in this handler tells rails.js to submit the form anyway.
* // The blank required inputs are passed to this function in `elements`.
* return ! confirm("Would you like to submit the form with missing info?");
View
32 test/public/test/call-remote-callbacks.js
@@ -7,10 +7,10 @@ module('call-remote-callbacks', {
}));
},
teardown: function() {
- $('form[data-remote]').die('ajax:beforeSend');
- $('form[data-remote]').die('ajax:before');
- $('form[data-remote]').die('ajax:complete');
- $('form[data-remote]').die('ajax:success');
+ $(document).undelegate('form[data-remote]', 'ajax:beforeSend');
+ $(document).undelegate('form[data-remote]', 'ajax:before');
+ $(document).undelegate('form[data-remote]', 'ajax:complete');
+ $(document).undelegate('form[data-remote]', 'ajax:success');
}
});
@@ -29,7 +29,7 @@ asyncTest('modifying form fields with "ajax:before" sends modified data in reque
$('form[data-remote]')
.append($('<input type="text" name="user_name" value="john">'))
.append($('<input type="text" name="removed_user_name" value="john">'))
- .live('ajax:before', function() {
+ .bind('ajax:before', function() {
var form = $(this);
form
.append($('<input />',{name: 'other_user_name',value: 'jonathan'}))
@@ -49,7 +49,7 @@ asyncTest('modifying form fields with "ajax:before" sends modified data in reque
asyncTest('modifying data("type") with "ajax:before" requests new dataType in request', 2, function(){
$('form[data-remote]').data('type','html')
- .live('ajax:before', function() {
+ .bind('ajax:before', function() {
var form = $(this);
form.data('type','xml')
});
@@ -63,7 +63,7 @@ asyncTest('modifying data("type") with "ajax:before" requests new dataType in re
asyncTest('setting data("cross-domain",true) with "ajax:before" uses new setting in request', 2, function(){
$('form[data-remote]').data('cross-domain',false)
- .live('ajax:before', function() {
+ .bind('ajax:before', function() {
var form = $(this);
form.data('cross-domain',true)
});
@@ -77,7 +77,7 @@ asyncTest('setting data("cross-domain",true) with "ajax:before" uses new setting
asyncTest('setting data("with-credentials",true) with "ajax:before" uses new setting in request', 2, function(){
$('form[data-remote]').data('with-credentials',false)
- .live('ajax:before', function() {
+ .bind('ajax:before', function() {
var form = $(this);
form.data('with-credentials',true);
});
@@ -304,7 +304,7 @@ function skipIt() {
}
asyncTest('"ajax:beforeSend" can be observed and stopped with event delegation', 1, function() {
- $('form[data-remote]').live('ajax:beforeSend', function() {
+ $(document).delegate('form[data-remote]', 'ajax:beforeSend', function() {
ok(true, 'ajax:beforeSend observed with event delegation');
return false;
});
@@ -353,18 +353,18 @@ asyncTest('"ajax:beforeSend", "ajax:error" and "ajax:complete" are triggered on
});
// IF THIS TEST IS FAILING, TRY INCREASING THE TIMEOUT AT THE BOTTOM TO > 100
-asyncTest('binding to ajax callbacks via .live() triggers handlers properly', 3, function() {
- $('form[data-remote]')
- .live('ajax:beforeSend', function() {
+asyncTest('binding to ajax callbacks via .delegate() triggers handlers properly', 3, function() {
+ $(document)
+ .delegate('form[data-remote]', 'ajax:beforeSend', function() {
ok(true, 'ajax:beforeSend handler is triggered');
})
- .live('ajax:complete', function() {
+ .delegate('form[data-remote]', 'ajax:complete', function() {
ok(true, 'ajax:complete handler is triggered');
})
- .live('ajax:success', function() {
+ .delegate('form[data-remote]', 'ajax:success', function() {
ok(true, 'ajax:success handler is triggered');
- })
- .trigger('submit');
+ });
+ $('form[data-remote]').trigger('submit');
setTimeout(function() {
start();
View
8 test/public/test/data-disable.js
@@ -162,9 +162,11 @@ asyncTest('a[data-remote][data-disable-with] disables and re-enables', 6, functi
.bind('ajax:beforeSend', function() {
checkDisabledState(link, 'clicking...');
})
- .live('ajax:complete', function() {
- checkEnabledState(link, 'Click me');
- start();
+ .bind('ajax:complete', function() {
+ setTimeout( function() {
+ checkEnabledState(link, 'Click me');
+ start();
+ }, 15);
})
.trigger('click');
});

0 comments on commit f22f74a

Please sign in to comment.