Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #226 from Oktavilla/use-delegate

Changed event handling from $.live to $.delegate
  • Loading branch information...
commit b5273c5c8818f5a6d044465ba665f2f2cbee4fc3 2 parents 4fe3753 + 86ed174
@wycats wycats authored
Showing with 8 additions and 8 deletions.
  1. +8 −8 src/rails.js
View
16 src/rails.js
@@ -287,11 +287,11 @@
$.ajaxPrefilter(function(options, originalOptions, xhr){ if ( !options.crossDomain ) { rails.CSRFProtection(xhr); }});
- $(rails.linkDisableSelector).live('ajax:complete', function() {
+ $(document).delegate(rails.linkDisableSelector, 'ajax:complete', function() {
rails.enableElement($(this));
});
- $(rails.linkClickSelector).live('click.rails', function(e) {
+ $(document).delegate(rails.linkClickSelector, 'click.rails', function(e) {
var link = $(this), method = link.data('method'), data = link.data('params');
if (!rails.allowAction(link)) return rails.stopEverything(e);
@@ -307,7 +307,7 @@
}
});
- $(rails.inputChangeSelector).live('change.rails', function(e) {
+ $(document).delegate(rails.inputChangeSelector, 'change.rails', function(e) {
var link = $(this);
if (!rails.allowAction(link)) return rails.stopEverything(e);
@@ -315,7 +315,7 @@
return false;
});
- $(rails.formSubmitSelector).live('submit.rails', function(e) {
+ $(document).delegate(rails.formSubmitSelector, 'submit.rails', function(e) {
var form = $(this),
remote = form.data('remote') !== undefined,
blankRequiredInputs = rails.blankInputs(form, rails.requiredInputSelector),
@@ -345,7 +345,7 @@
}
});
- $(rails.formInputClickSelector).live('click.rails', function(event) {
+ $(document).delegate(rails.formInputClickSelector, 'click.rails', function(event) {
var button = $(this);
if (!rails.allowAction(button)) return rails.stopEverything(event);
@@ -357,12 +357,12 @@
button.closest('form').data('ujs:submit-button', data);
});
- $(rails.formSubmitSelector).live('ajax:beforeSend.rails', function(event) {
+ $(document).delegate(rails.formSubmitSelector, 'ajax:beforeSend.rails', function(event) {
if (this == event.target) rails.disableFormElements($(this));
});
- $(rails.formSubmitSelector).live('ajax:complete.rails', function(event) {
+ $(document).delegate(rails.formSubmitSelector, 'ajax:complete.rails', function(event) {
if (this == event.target) rails.enableFormElements($(this));
});
-})( jQuery );
+})( jQuery );
Please sign in to comment.
Something went wrong with that request. Please try again.