Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
drupal
Commits
9c8c3cfd
Commit
9c8c3cfd
authored
15 years ago
by
Dries Buytaert
Browse files
Options
Downloads
Patches
Plain Diff
- Patch
#396466
by quicksketch: support custom success callbacks in ahah.js.
parent
c6cf7034
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!7452
Issue #1797438. HTML5 validation is preventing form submit and not fully...
,
!789
Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
misc/ahah.js
+39
-8
39 additions, 8 deletions
misc/ahah.js
with
39 additions
and
8 deletions
misc/ahah.js
+
39
−
8
View file @
9c8c3cfd
...
...
@@ -13,6 +13,8 @@
* to provide AHAH capabilities.
*/
Drupal
.
ahah
=
Drupal
.
ahah
||
{};
/**
* Attaches the ahah behavior to each ahah form element.
*/
...
...
@@ -24,7 +26,7 @@ Drupal.behaviors.ahah = {
$
(
element_settings
.
selector
).
each
(
function
()
{
element_settings
.
element
=
this
;
var
ahah
=
new
Drupal
.
ahah
(
base
,
element_settings
);
Drupal
.
ahah
[
base
]
=
new
Drupal
.
ahah
(
base
,
element_settings
);
});
$
(
'
#
'
+
base
).
addClass
(
'
ahah-processed
'
);
...
...
@@ -35,6 +37,24 @@ Drupal.behaviors.ahah = {
/**
* AHAH object.
*
* All AHAH objects on a page are accessible through the global Drupal.ahah object
* and are keyed by the submit button's ID. You can access them from your module's
* JavaScript file to override properties or functions.
* For example, if your AHAH enabled button has the ID 'edit-submit', you can
* redefine the function that is called to insert the new content like this
* (inside a Drupal.behaviors attach block):
* @code
* Drupal.behaviors.myCustomAhahStuff = {
* attach: function(context, settings) {
* Drupal.ahah['edit-submit'].insertNewContent = function(response, status) {
* new_content = $(response.data);
* $('#my-wrapper').append(new_content);
* alert('New content was appended to #my-wrapper');
* }
* }
* };
* @endcode
*/
Drupal
.
ahah
=
function
(
base
,
element_settings
)
{
// Set the properties for this object.
...
...
@@ -149,11 +169,7 @@ Drupal.ahah.prototype.beforeSubmit = function (form_values, element, options) {
* Handler for the form redirection completion.
*/
Drupal
.
ahah
.
prototype
.
success
=
function
(
response
,
status
)
{
var
wrapper
=
$
(
this
.
wrapper
);
var
form
=
$
(
this
.
element
).
parents
(
'
form
'
);
// Manually insert HTML into the jQuery object, using $() directly crashes
// Safari with long string lengths. http://dev.jquery.com/ticket/1152
var
new_content
=
$
(
'
<div></div>
'
).
html
(
response
.
data
);
// Restore the previous action and target to the form.
form
.
attr
(
'
action
'
,
this
.
form_action
);
...
...
@@ -169,8 +185,25 @@ Drupal.ahah.prototype.success = function (response, status) {
}
$
(
this
.
element
).
removeClass
(
'
progress-disabled
'
).
attr
(
'
disabled
'
,
false
);
// Add the new content to the page.
Drupal
.
freezeHeight
();
// Call the insertNewContent handler to insert the new content into the page.
this
.
insertNewContent
(
response
,
status
);
Drupal
.
unfreezeHeight
();
};
/**
* Handler to insert the new content into the page.
*/
Drupal
.
ahah
.
prototype
.
insertNewContent
=
function
(
response
,
status
)
{
var
wrapper
=
$
(
this
.
wrapper
);
// Manually insert HTML into the jQuery object, using $() directly crashes
// Safari with long string lengths. http://dev.jquery.com/ticket/1152
var
new_content
=
$
(
'
<div></div>
'
).
html
(
response
.
data
);
// Add the new content to the page.
if
(
this
.
method
==
'
replace
'
)
{
wrapper
.
empty
().
append
(
new_content
);
}
...
...
@@ -201,8 +234,6 @@ Drupal.ahah.prototype.success = function (response, status) {
var
settings
=
response
.
settings
||
Drupal
.
settings
;
Drupal
.
attachBehaviors
(
new_content
,
settings
);
}
Drupal
.
unfreezeHeight
();
};
/**
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment