summaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2010-12-23 04:26:31 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2010-12-23 04:26:31 +0000
commite658064759d54e0d43872a5430ad0381366b0bcd (patch)
tree319818090c7100a0c6a7c7912a532f767d664d6f /misc
parentbb344c82d5c61f9259d54c247aef26f71419022a (diff)
downloadbrdo-e658064759d54e0d43872a5430ad0381366b0bcd.tar.gz
brdo-e658064759d54e0d43872a5430ad0381366b0bcd.tar.bz2
#995854 by rfay, effulgentsia, sun, merlinofchaos, Damien Tournoud, manimejia: Fixed #ajax doesn't work at all if a file element (or enctype => 'multipart/form-data') is included in the form
Diffstat (limited to 'misc')
-rw-r--r--misc/ajax.js19
1 files changed, 16 insertions, 3 deletions
diff --git a/misc/ajax.js b/misc/ajax.js
index 57a16048e..b17e64a9f 100644
--- a/misc/ajax.js
+++ b/misc/ajax.js
@@ -152,9 +152,9 @@ Drupal.ajax = function (base, element, element_settings) {
ajax.ajaxing = true;
return ajax.beforeSubmit(form_values, element_settings, options);
},
- beforeSend: function (xmlhttprequest) {
+ beforeSend: function (xmlhttprequest, options) {
ajax.ajaxing = true;
- return ajax.beforeSend(xmlhttprequest, ajax.options);
+ return ajax.beforeSend(xmlhttprequest, options);
},
success: function (response, status) {
// Sanity check for browser support (object expected).
@@ -318,7 +318,20 @@ Drupal.ajax.prototype.beforeSubmit = function (form_values, element, options) {
* Prepare the AJAX request before it is sent.
*/
Drupal.ajax.prototype.beforeSend = function (xmlhttprequest, options) {
- // Disable the element that received the change.
+ // Disable the element that received the change to prevent user interface
+ // interaction while the AJAX request is in progress. ajax.ajaxing prevents
+ // the element from triggering a new request, but does not prevent the user
+ // from changing its value.
+ // Forms without file inputs are already serialized before this function is
+ // called. Forms with file inputs use an IFRAME to perform a POST request
+ // similar to a browser, so disabled elements are not contained in the
+ // submitted values. Therefore, we manually add the element's value to
+ // options.extraData.
+ var v = $.fieldValue(this.element);
+ if (v !== null) {
+ options.extraData = options.extraData || {};
+ options.extraData[this.element.name] = v;
+ }
$(this.element).addClass('progress-disabled').attr('disabled', true);
// Insert progressbar or throbber.