diff --git misc/ajax.js misc/ajax.js index d0025e6..99b6a38 100644 --- misc/ajax.js +++ misc/ajax.js @@ -86,6 +86,7 @@ Drupal.behaviors.AJAX = { * @endcode */ Drupal.ajax = function (base, element, element_settings) { + var defaults = { url: 'system/ajax', event: 'mousedown', @@ -104,6 +105,8 @@ Drupal.ajax = function (base, element, element_settings) { $.extend(this, defaults, element_settings); this.element = element; + // Turn off the normal form submit, since we will use this only with AJAX. + $(element).submit(function() { return false; }); // Replacing 'nojs' with 'ajax' in the URL allows for an easy method to let // the server detect when it needs to degrade gracefully. @@ -188,6 +191,9 @@ Drupal.ajax = function (base, element, element_settings) { * before field data is collected. */ Drupal.ajax.prototype.beforeSerialize = function (element, options) { + // Disable the element that received the change. + $(this.element).addClass('progress-disabled').attr('disabled', true); + // Allow detaching behaviors to update field values before collecting them. var settings = this.settings || Drupal.settings; Drupal.detachBehaviors(this.form, settings, 'serialize'); @@ -197,8 +203,6 @@ Drupal.ajax.prototype.beforeSerialize = function (element, options) { * Handler for the form redirection submission. */ Drupal.ajax.prototype.beforeSubmit = function (form_values, element, options) { - // Disable the element that received the change. - $(this.element).addClass('progress-disabled').attr('disabled', true); // Server-side code needs to know what element triggered the call, so it can // find the #ajax binding.