Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Updated to latest jquery-ujs, delegate and bug fixes

  • Loading branch information...
commit 859e37448ed32fddde45cf0daed6f4f7a3d3ddf2 1 parent 546029a
@JangoSteve JangoSteve authored
View
2  lib/jquery/rails/version.rb
@@ -3,6 +3,6 @@ module Rails
VERSION = "1.0.18"
JQUERY_VERSION = "1.7.0"
JQUERY_UI_VERSION = "1.8.16"
- JQUERY_UJS_VERSION = "4fe37537cb2d8e71005303d3acb469e6205d26db"
+ JQUERY_UJS_VERSION = "82292010fb1743f038ab72b1f1e994e91be3eda3"
end
end
View
27 vendor/assets/javascripts/jquery_ujs.js
@@ -52,8 +52,8 @@
// Link elements bound by jquery-ujs
linkClickSelector: 'a[data-confirm], a[data-method], a[data-remote], a[data-disable-with]',
- // Select elements bound by jquery-ujs
- inputChangeSelector: 'select[data-remote], input[data-remote], textarea[data-remote]',
+ // Select elements bound by jquery-ujs
+ inputChangeSelector: 'select[data-remote], input[data-remote], textarea[data-remote]',
// Form elements bound by jquery-ujs
formSubmitSelector: 'form',
@@ -151,7 +151,9 @@
// Only pass url to `ajax` options if not blank
if (url) { options.url = url; }
- rails.ajax(options);
+ return rails.ajax(options);
+ } else {
+ return false;
}
},
@@ -287,11 +289,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);
@@ -299,15 +301,17 @@
if (link.data('remote') !== undefined) {
if ( (e.metaKey || e.ctrlKey) && (!method || method === 'GET') && !data ) { return true; }
- rails.handleRemote(link);
+
+ if (rails.handleRemote(link) === false) { rails.enableElement(link); }
return false;
+
} else if (link.data('method')) {
rails.handleMethod(link);
return false;
}
});
- $(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 +319,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),
@@ -339,13 +343,14 @@
rails.handleRemote(form);
return false;
+
} else {
// slight timeout so that the submit button gets properly serialized
setTimeout(function(){ rails.disableFormElements(form); }, 13);
}
});
- $(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,11 +362,11 @@
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));
});
Please sign in to comment.
Something went wrong with that request. Please try again.