Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
drupal
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
220
Merge Requests
220
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
drupal
Commits
87e5ebe7
Commit
87e5ebe7
authored
Jul 21, 2011
by
webchick
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#634616
follow-up by sun: Documentation and bug fix for 'prevent' AJAX property.
parent
3acfe361
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
1 deletion
+19
-1
includes/ajax.inc
includes/ajax.inc
+19
-1
No files found.
includes/ajax.inc
View file @
87e5ebe7
...
@@ -143,6 +143,21 @@
...
@@ -143,6 +143,21 @@
* - #ajax['event']: The JavaScript event to respond to. This is normally
* - #ajax['event']: The JavaScript event to respond to. This is normally
* selected automatically for the type of form widget being used, and
* selected automatically for the type of form widget being used, and
* is only needed if you need to override the default behavior.
* is only needed if you need to override the default behavior.
* - #ajax['prevent']: A JavaScript event to prevent when 'event' is triggered.
* Defaults to 'click' for #ajax on #type 'submit', 'button', and
* 'image_button'. Multiple events may be specified separated by spaces.
* For example, when binding #ajax behaviors to form buttons, pressing the
* ENTER key within a textfield triggers the 'click' event of the form's first
* submit button. Triggering Ajax in this situation leads to problems, like
* breaking autocomplete textfields. Because of that, Ajax behaviors are bound
* to the 'mousedown' event on form buttons by default. However, binding to
* 'mousedown' rather than 'click' means that it is possible to trigger a
* click by pressing the mouse, holding the mouse button down until the Ajax
* request is complete and the button is re-enabled, and then releasing the
* mouse button. For this case, 'prevent' can be set to 'click', so an
* additional event handler is bound to prevent such a click from triggering a
* non-Ajax form submission. This also prevents a textfield's ENTER press
* triggering a button's non-Ajax form submission behavior.
* - #ajax['method']: The jQuery method to use to place the new HTML.
* - #ajax['method']: The jQuery method to use to place the new HTML.
* Defaults to 'replaceWith'. May be: 'replaceWith', 'append', 'prepend',
* Defaults to 'replaceWith'. May be: 'replaceWith', 'append', 'prepend',
* 'before', 'after', or 'html'. See the
* 'before', 'after', or 'html'. See the
...
@@ -591,6 +606,7 @@ function ajax_process_form($element, &$form_state) {
...
@@ -591,6 +606,7 @@ function ajax_process_form($element, &$form_state) {
* An associative array containing the properties of the element.
* An associative array containing the properties of the element.
* Properties used:
* Properties used:
* - #ajax['event']
* - #ajax['event']
* - #ajax['prevent']
* - #ajax['path']
* - #ajax['path']
* - #ajax['options']
* - #ajax['options']
* - #ajax['wrapper']
* - #ajax['wrapper']
...
@@ -636,7 +652,9 @@ function ajax_pre_render_element($element) {
...
@@ -636,7 +652,9 @@ function ajax_pre_render_element($element) {
// an additional handler to prevent such a click from triggering a
// an additional handler to prevent such a click from triggering a
// non-Ajax form submission. This also prevents a textfield's ENTER
// non-Ajax form submission. This also prevents a textfield's ENTER
// press triggering this button's non-Ajax form submission behavior.
// press triggering this button's non-Ajax form submission behavior.
$element
[
'#ajax'
][
'prevent'
]
=
'click'
;
if
(
!
isset
(
$element
[
'#ajax'
][
'prevent'
]))
{
$element
[
'#ajax'
][
'prevent'
]
=
'click'
;
}
break
;
break
;
case
'password'
:
case
'password'
:
...
...
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