Index: includes/ajax.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/ajax.inc,v retrieving revision 1.40 diff -u -p -r1.40 ajax.inc --- includes/ajax.inc 17 Dec 2010 01:03:58 -0000 1.40 +++ includes/ajax.inc 21 Dec 2010 02:15:19 -0000 @@ -567,7 +567,7 @@ function ajax_pre_render_element($elemen } // Add a reasonable default event handler if none was specified. - if (isset($element['#ajax']) && !isset($element['#ajax']['event'])) { + if (!isset($element['#ajax']['event'])) { switch ($element['#type']) { case 'submit': case 'button': @@ -602,6 +602,25 @@ function ajax_pre_render_element($elemen } } + // By default, prevent the browser from performing the default action of the + // event to which AJAX is binding. However, in Internet Explorer, preventing + // the default action of a radio or checkbox 'change' event prevents the + // element from being checked or unchecked. + // @todo For Drupal 8, revisit this logic. Perhaps not just radio and checkbox + // elements, but everything other than buttons and links should default to + // TRUE. + if (!isset($element['#ajax']['allow_default_action'])) { + switch ($element['#type']) { + case 'radio': + case 'checkbox': + $element['#ajax']['allow_default_action'] = TRUE; + break; + + default: + $element['#ajax']['allow_default_action'] = FALSE; + } + } + // Attach JavaScript settings to the element. if (isset($element['#ajax']['event'])) { $element['#attached']['library'][] = array('system', 'jquery.form'); Index: misc/ajax.js =================================================================== RCS file: /cvs/drupal/drupal/misc/ajax.js,v retrieving revision 1.33 diff -u -p -r1.33 ajax.js --- misc/ajax.js 17 Dec 2010 01:03:58 -0000 1.33 +++ misc/ajax.js 21 Dec 2010 02:15:21 -0000 @@ -111,7 +111,8 @@ Drupal.ajax = function (base, element, e }, submit: { 'js': true - } + }, + allow_default_action: false }; $.extend(this, defaults, element_settings); @@ -221,7 +222,7 @@ Drupal.ajax.prototype.eventResponse = fu // Do not perform another ajax command if one is already in progress. if (ajax.ajaxing) { - return false; + return ajax.element_settings.allow_default_action; } try { @@ -250,15 +251,7 @@ Drupal.ajax.prototype.eventResponse = fu alert("An error occurred while attempting to process " + ajax.options.url + ": " + e.message); } - // For radio/checkbox, allow the default event. On IE, this means letting - // it actually check the box. - if (typeof element.type != 'undefined' && (element.type == 'checkbox' || element.type == 'radio')) { - return true; - } - else { - return false; - } - + return ajax.element_settings.allow_default_action; }; /**