summaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2010-09-22 21:01:39 +0000
committerDries Buytaert <dries@buytaert.net>2010-09-22 21:01:39 +0000
commitf7af8511c49ce15b699a9001b8fbe735516c1c12 (patch)
treeeb775c2be7720844b9391c1d82d90e34e60d91cb /misc
parent0317fc941116880daebce119989432b716407769 (diff)
downloadbrdo-f7af8511c49ce15b699a9001b8fbe735516c1c12.tar.gz
brdo-f7af8511c49ce15b699a9001b8fbe735516c1c12.tar.bz2
- Patch #850612 by Meriial, merlinofchaos, adrian: setting class 'use-ajax-submit' for form submission causes js error(s).
Diffstat (limited to 'misc')
-rw-r--r--misc/ajax.js49
1 files changed, 34 insertions, 15 deletions
diff --git a/misc/ajax.js b/misc/ajax.js
index 0c83d7776..616195463 100644
--- a/misc/ajax.js
+++ b/misc/ajax.js
@@ -55,7 +55,13 @@ Drupal.behaviors.AJAX = {
// AJAX submits specified in this manner automatically submit to the
// normal form action.
element_settings.url = $(this.form).attr('action');
- element_settings.set_click = TRUE;
+ // Form submit button clicks need to tell the form what was clicked so
+ // it gets passed in the POST request.
+ element_settings.setClick = true;
+ // Form buttons use the 'click' event rather than mousedown.
+ element_settings.event = 'click';
+ // Clicked form buttons look better with the throbber than the progress bar.
+ element_settings.progress = { 'type': 'throbber' };
var base = $(this).attr('id');
Drupal.ajax[base] = new Drupal.ajax(base, this, element_settings);
@@ -98,7 +104,9 @@ Drupal.ajax = function (base, element, element_settings) {
type: 'bar',
message: 'Please wait...'
},
- submit: {}
+ submit: {
+ 'js': true
+ }
};
$.extend(this, defaults, element_settings);
@@ -126,6 +134,7 @@ Drupal.ajax = function (base, element, element_settings) {
return ajax.beforeSerialize(element_settings, options);
},
beforeSubmit: function (form_values, element_settings, options) {
+ ajax.ajaxing = true;
return ajax.beforeSubmit(form_values, element_settings, options);
},
success: function (response, status) {
@@ -137,6 +146,7 @@ Drupal.ajax = function (base, element, element_settings) {
return ajax.success(response, status);
},
complete: function (response, status) {
+ ajax.ajaxing = false;
if (status == 'error' || status == 'parsererror') {
return ajax.error(response, ajax.url);
}
@@ -147,21 +157,30 @@ Drupal.ajax = function (base, element, element_settings) {
// Bind the ajaxSubmit function to the element event.
$(this.element).bind(element_settings.event, function () {
- if (ajax.form) {
- // If setClick is set, we must set this to ensure that the button's
- // value is passed.
- if (ajax.setClick) {
- // Mark the clicked button. 'form.clk' is a special variable for
- // ajaxSubmit that tells the system which element got clicked to
- // trigger the submit. Without it there would be no 'op' or
- // equivalent.
- ajax.form.clk = this.element;
- }
+ if (ajax.ajaxing) {
+ return false;
+ }
- ajax.form.ajaxSubmit(options);
+ try {
+ if (ajax.form) {
+ // If setClick is set, we must set this to ensure that the button's
+ // value is passed.
+ if (ajax.setClick) {
+ // Mark the clicked button. 'form.clk' is a special variable for
+ // ajaxSubmit that tells the system which element got clicked to
+ // trigger the submit. Without it there would be no 'op' or
+ // equivalent.
+ ajax.form.clk = this.element;
+ }
+
+ ajax.form.ajaxSubmit(options);
+ }
+ else {
+ $.ajax(options);
+ }
}
- else {
- $.ajax(options);
+ catch (e) {
+ alert("An error occurred while attempting to process " + options.url + ": " + e.message);
}
return false;