summaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2010-12-21 04:21:16 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2010-12-21 04:21:16 +0000
commit13d9e0b0f8ce89ac313cbe19d0d56b7d445d1555 (patch)
treeec541bcf748b3de1b1e739019072a33c5c57ba47 /misc
parent2d9916e6f6edda8841cf1251f30761818f799f45 (diff)
downloadbrdo-13d9e0b0f8ce89ac313cbe19d0d56b7d445d1555.tar.gz
brdo-13d9e0b0f8ce89ac313cbe19d0d56b7d445d1555.tar.bz2
#995122 by threewestwinds, rfay: Allow textareas and textfields to accept spaces in ajax.
Diffstat (limited to 'misc')
-rw-r--r--misc/ajax.js10
1 files changed, 8 insertions, 2 deletions
diff --git a/misc/ajax.js b/misc/ajax.js
index 4672e3eb3..57a16048e 100644
--- a/misc/ajax.js
+++ b/misc/ajax.js
@@ -195,13 +195,19 @@ Drupal.ajax = function (base, element, element_settings) {
* The AJAX object will, if instructed, bind to a key press response. This
* will test to see if the key press is valid to trigger this event and
* if it is, trigger it for us and prevent other keypresses from triggering.
+ * In this case we're handling RETURN and SPACEBAR keypresses (event codes 13
+ * and 32. RETURN is often used to submit a form when in a textfield, and
+ * SPACE is often used to activate an element without submitting.
*/
Drupal.ajax.prototype.keypressResponse = function (element, event) {
// Create a synonym for this to reduce code confusion.
var ajax = this;
- // Detect enter key and space bar.
- if (event.which == 13 || event.which == 32) {
+ // Detect enter key and space bar and allow the standard response for them,
+ // except for form elements of type 'text' and 'textarea', where the
+ // spacebar activation causes inappropriate activation if #ajax['keypress'] is
+ // TRUE. On a text-type widget a space should always be a space.
+ if (event.which == 13 || (event.which == 32 && element.type != 'text' && element.type != 'textarea')) {
$(ajax.element_settings.element).trigger(ajax.element_settings.event);
return false;
}