Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
13d9e0b0
Commit
13d9e0b0
authored
Dec 21, 2010
by
webchick
Browse files
#995122
by threewestwinds, rfay: Allow textareas and textfields to accept spaces in ajax.
parent
2d9916e6
Changes
1
Show whitespace changes
Inline
Side-by-side
misc/ajax.js
View file @
13d9e0b0
...
...
@@ -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
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment