From 3cbd47d1458b9914d0ede84fd31d4ecc0c8e684b Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Thu, 21 Oct 2010 19:31:39 +0000 Subject: - Patch #647228 by sun, katbailey, Rob Loach: links are needlessly unable to fully participate in D7 AJAX framework features. --- misc/ajax.js | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) (limited to 'misc') diff --git a/misc/ajax.js b/misc/ajax.js index 773986ae3..570e2aaed 100644 --- a/misc/ajax.js +++ b/misc/ajax.js @@ -176,6 +176,7 @@ Drupal.ajax = function (base, element, element_settings) { ajax.form.ajaxSubmit(ajax.options); } else { + ajax.beforeSerialize(ajax.element, ajax.options); $.ajax(ajax.options); } } @@ -216,31 +217,35 @@ Drupal.ajax.prototype.beforeSerialize = function (element, options) { var settings = this.settings || Drupal.settings; Drupal.detachBehaviors(this.form, settings, 'serialize'); } -}; - -/** - * 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); // Prevent duplicate HTML ids in the returned markup. // @see drupal_html_id() + options.data['ajax_html_ids[]'] = []; $('[id]').each(function () { - form_values.push({ name: 'ajax_html_ids[]', value: this.id }); + options.data['ajax_html_ids[]'].push(this.id); }); // Allow Drupal to return new JavaScript and CSS files to load without // returning the ones already loaded. - form_values.push({ name: 'ajax_page_state[theme]', value: Drupal.settings.ajaxPageState.theme }); - form_values.push({ name: 'ajax_page_state[theme_token]', value: Drupal.settings.ajaxPageState.themeToken }); + // @see ajax_base_page_theme() + // @see drupal_get_css() + // @see drupal_get_js() + options.data['ajax_page_state[theme]'] = Drupal.settings.ajaxPageState.theme; + options.data['ajax_page_state[theme_token]'] = Drupal.settings.ajaxPageState.theme_token; for (var key in Drupal.settings.ajaxPageState.css) { - form_values.push({ name: 'ajax_page_state[css][' + key + ']', value: 1 }); + options.data['ajax_page_state[css][' + key + ']'] = 1; } for (var key in Drupal.settings.ajaxPageState.js) { - form_values.push({ name: 'ajax_page_state[js][' + key + ']', value: 1 }); + options.data['ajax_page_state[js][' + key + ']'] = 1; } +}; + +/** + * 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); // Insert progressbar or throbber. if (this.progress.type == 'bar') { @@ -279,7 +284,7 @@ Drupal.ajax.prototype.success = function (response, status) { Drupal.freezeHeight(); - for (i in response) { + for (var i in response) { if (response[i]['command'] && this.commands[response[i]['command']]) { this.commands[response[i]['command']](this, response[i], status); } -- cgit v1.2.3