Index: includes/ajax.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/ajax.inc,v retrieving revision 1.41 diff -u -p -r1.41 ajax.inc --- includes/ajax.inc 23 Dec 2010 04:26:31 -0000 1.41 +++ includes/ajax.inc 26 Dec 2010 22:02:10 -0000 @@ -587,13 +587,8 @@ function ajax_pre_render_element($elemen case 'submit': case 'button': case 'image_button': - // Use the mousedown instead of the click event because form - // submission via pressing the enter key triggers a click event on - // submit inputs, inappropriately triggering AJAX behaviors. - $element['#ajax']['event'] = 'mousedown'; - // Attach an additional event handler so that AJAX behaviors - // can be triggered still via keyboard input. - $element['#ajax']['keypress'] = TRUE; + case 'link': + $element['#ajax']['event'] = 'click'; break; case 'password': @@ -608,10 +603,6 @@ function ajax_pre_render_element($elemen $element['#ajax']['event'] = 'change'; break; - case 'link': - $element['#ajax']['event'] = 'click'; - break; - default: return $element; } Index: misc/ajax.js =================================================================== RCS file: /cvs/drupal/drupal/misc/ajax.js,v retrieving revision 1.35 diff -u -p -r1.35 ajax.js --- misc/ajax.js 23 Dec 2010 04:26:31 -0000 1.35 +++ misc/ajax.js 26 Dec 2010 22:02:10 -0000 @@ -55,7 +55,7 @@ Drupal.behaviors.AJAX = { // This class means to submit the form to the action using AJAX. $('.use-ajax-submit:not(.ajax-processed)').addClass('ajax-processed').each(function () { - var element_settings = {}; + var element_settings = {event: 'click'}; // AJAX submits specified in this manner automatically submit to the // normal form action. @@ -63,14 +63,33 @@ Drupal.behaviors.AJAX = { // 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' }; + element_settings.progress = {'type': 'throbber'}; var base = $(this).attr('id'); Drupal.ajax[base] = new Drupal.ajax(base, this, element_settings); }); + + // Some browsers (e.g., Firefox) trigger the click event of the first submit + // button when ENTER is pressed from a textfield. Some browsers (e.g., IE7) + // trigger form submission directly rather than triggering a button click, + // but the Form API processes this as though the first button were clicked. + // Some browsers invoke this implicit submission behavior only when a single + // textfield exists on the form; others invoke it regardless of how many + // textfields are on the form. In any case, when AJAX is bound to the first + // submit button, disable this browser behavior, because it is unlikely that + // the user intended to trigger the button's AJAX behavior when pressing + // ENTER from a textfield. + // @see http://drupal.org/node/634616 + $('input:text', context).once('ajax-prevent-implicit-activation', function() { + // Namespace the event so that modules may unbind it and replace with an + // alternate implementation. + $(this).bind('keypress.ajaxPreventImplicitActivation', function(event) { + if (event.which == 13 && $('input:submit, input:image', this.form).filter(':eq(0)').filter('.ajax-processed').length) { + event.preventDefault(); + } + }); + }); } }; @@ -99,8 +118,8 @@ Drupal.behaviors.AJAX = { Drupal.ajax = function (base, element, element_settings) { var defaults = { url: 'system/ajax', - event: 'mousedown', - keypress: true, + event: 'click', + keypress: false, selector: '#' + base, effect: 'none', speed: 'none', Index: modules/field_ui/field_ui.js =================================================================== RCS file: /cvs/drupal/drupal/modules/field_ui/field_ui.js,v retrieving revision 1.8 diff -u -p -r1.8 field_ui.js --- modules/field_ui/field_ui.js 21 Nov 2010 08:50:49 -0000 1.8 +++ modules/field_ui/field_ui.js 26 Dec 2010 22:03:16 -0000 @@ -236,7 +236,7 @@ Drupal.fieldUIOverview = { // Fire the AJAX update. $('input[name=refresh_rows]').val(rowNames.join(' ')); - $('input#edit-refresh').mousedown(); + $('input#edit-refresh').click(); // Disabled elements do not appear in POST ajax data, so we mark the // elements disabled only after firing the request. Index: modules/file/file.js =================================================================== RCS file: /cvs/drupal/drupal/modules/file/file.js,v retrieving revision 1.6 diff -u -p -r1.6 file.js --- modules/file/file.js 23 Nov 2010 05:51:16 -0000 1.6 +++ modules/file/file.js 26 Dec 2010 22:03:16 -0000 @@ -37,12 +37,12 @@ Drupal.behaviors.fileValidateAutoAttach */ Drupal.behaviors.fileButtons = { attach: function (context) { - $('input.form-submit', context).bind('mousedown', Drupal.file.disableFields); - $('div.form-managed-file input.form-submit', context).bind('mousedown', Drupal.file.progressBar); + $('input.form-submit', context).bind('click', Drupal.file.disableFields); + $('div.form-managed-file input.form-submit', context).bind('click', Drupal.file.progressBar); }, detach: function (context) { - $('input.form-submit', context).unbind('mousedown', Drupal.file.disableFields); - $('div.form-managed-file input.form-submit', context).unbind('mousedown', Drupal.file.progressBar); + $('input.form-submit', context).unbind('click', Drupal.file.disableFields); + $('div.form-managed-file input.form-submit', context).unbind('click', Drupal.file.progressBar); } }; @@ -105,10 +105,11 @@ Drupal.file = Drupal.file || { // working with. Filter out fields that are already disabled so that they // do not get enabled when we re-enable these fields at the end of behavior // processing. Re-enable in a setTimeout set to a relatively short amount - // of time (1 second). All the other mousedown handlers (like Drupal's AJAX - // behaviors) are excuted before any timeout functions are called, so we - // don't have to worry about the fields being re-enabled too soon. - // @todo If the previous sentence is true, why not set the timeout to 0? + // of time (1 second). For AJAX form submissions involving file uploads, the + // browser's native form submission (to an IFRAME), rather than JavaScript + // serialization to an XHR object, is used, so the fields must be disabled + // when the browser initiates the POST request. 1 second should be long + // enough. var $fieldsToTemporarilyDisable = $('div.form-managed-file input.form-file').not($enabledFields).not(':disabled'); $fieldsToTemporarilyDisable.attr('disabled', 'disabled'); setTimeout(function (){