Permalink
Browse files

Changed event handling from $.live to $.delegate

  • Loading branch information...
1 parent 4fe3753 commit 86ed1747ecf27bb72b2f82054032edcd3b84fb4f @martinlissmyr martinlissmyr committed Nov 24, 2011
Showing with 8 additions and 8 deletions.
  1. +8 −8 src/rails.js
View
@@ -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,15 +307,15 @@
}
});
- $(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);
rails.handleRemote(link);
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 );

0 comments on commit 86ed174

Please sign in to comment.