AjaxCommands

Drupal. AjaxCommands

new AjaxCommands()

Source:
Provide a series of commands that the client will perform.

Methods

add_css(ajaxopt, response, statusopt)

Source:
Command to add css.
Parameters:
Name Type Attributes Description
ajax Drupal.Ajax <optional>
Drupal.Ajax object created by Drupal.ajax.
response object The response from the Ajax request.
Properties
Name Type Description
data string A string that contains the styles to be added.
status number <optional>
The XMLHttpRequest status.

add_js(ajaxopt, response, statusopt)

Source:
Command to add JS.
Parameters:
Name Type Attributes Description
ajax Drupal.Ajax <optional>
Drupal.Ajax object created by Drupal.ajax.
response object The response from the Ajax request.
Properties
Name Type Description
data Array An array of objects of script attributes.
status number <optional>
The XMLHttpRequest status.

alert(ajaxopt, response, statusopt)

Source:
Command to provide an alert.
Parameters:
Name Type Attributes Description
ajax Drupal.Ajax <optional>
Drupal.Ajax object created by Drupal.ajax.
response object The JSON response from the Ajax request.
Properties
Name Type Description
text string The text that will be displayed in an alert dialog.
status number <optional>
The XMLHttpRequest status.

announce(ajaxopt, response)

Source:
Command to provide triggers audio UAs to read the supplied text.
Parameters:
Name Type Attributes Description
ajax Drupal.Ajax <optional>
Drupal.Ajax object created by Drupal.ajax.
response object The JSON response from the Ajax request.
Properties
Name Type Attributes Description
text string <optional>
The text that will be read.
priority string <optional>
An optional priority that will be used for the announcement.

changed(ajaxopt, response, statusopt)

Source:
Command to mark a chunk changed.
Parameters:
Name Type Attributes Description
ajax Drupal.Ajax <optional>
Drupal.Ajax object created by Drupal.ajax.
response object The JSON response object from the Ajax request.
Properties
Name Type Attributes Description
selector string A jQuery selector string.
asterisk boolean <optional>
An optional CSS selector. If specified, an asterisk will be appended to the HTML inside the provided selector.
status number <optional>
The request status.

css(ajaxopt, response, statusopt)

Source:
Command to provide the jQuery css() function.
Parameters:
Name Type Attributes Description
ajax Drupal.Ajax <optional>
Drupal.Ajax object created by Drupal.ajax.
response object The response from the Ajax request.
Properties
Name Type Description
selector string A jQuery selector string.
argument object An array of key/value pairs to set in the CSS for the selector.
status number <optional>
The XMLHttpRequest status.

data(ajaxopt, response, statusopt)

Source:
Command to attach data using jQuery's data API.
Parameters:
Name Type Attributes Description
ajax Drupal.Ajax <optional>
Drupal.Ajax object created by Drupal.ajax.
response object The response from the Ajax request.
Properties
Name Type Description
name string The name or key (in the key value pair) of the data attached to this selector.
selector string A jQuery selector string.
value string | object The value of to be attached.
status number <optional>
The XMLHttpRequest status.

focusFirst(ajaxopt, response, statusopt)

Source:
Command to focus the first tabbable element within a container. If no tabbable elements are found and the container is focusable, then focus will move to that container.
Parameters:
Name Type Attributes Description
ajax Drupal.Ajax <optional>
Drupal.Ajax object created by Drupal.ajax.
response object The response from the Ajax request.
Properties
Name Type Description
selector string A query selector string of the container to focus within.
status number <optional>
The XMLHttpRequest status.

insert(ajax, response)

Source:
Command to insert new content into the DOM.
Parameters:
Name Type Description
ajax Drupal.Ajax Drupal.Ajax object created by Drupal.ajax.
response object The response from the Ajax request.
Properties
Name Type Attributes Description
data string The data to use with the jQuery method.
method string <optional>
The jQuery DOM manipulation method to be used.
selector string <optional>
An optional jQuery selector string.
settings object <optional>
An optional array of settings that will be used.

invoke(ajaxopt, response, statusopt)

Source:
Command to apply a jQuery method.
Parameters:
Name Type Attributes Description
ajax Drupal.Ajax <optional>
Drupal.Ajax object created by Drupal.ajax.
response object The response from the Ajax request.
Properties
Name Type Description
args Array An array of arguments to the jQuery method, if any.
method string The jQuery method to invoke.
selector string A jQuery selector string.
status number <optional>
The XMLHttpRequest status.

message(ajaxopt, response)

Source:
Command to add a message to the message area.
Parameters:
Name Type Attributes Description
ajax Drupal.Ajax <optional>
Drupal.Ajax object created by Drupal.ajax.
response object The response from the Ajax request.
Properties
Name Type Description
messageWrapperQuerySelector string The zone where to add the message. If null, the default will be used.
message string The message text.
messageOptions string The options argument for Drupal.Message().add().
clearPrevious boolean If true, clear previous messages.

redirect(ajaxopt, response, statusopt)

Source:
Command to set the window.location, redirecting the browser.
Parameters:
Name Type Attributes Description
ajax Drupal.Ajax <optional>
Drupal.Ajax object created by Drupal.ajax.
response object The response from the Ajax request.
Properties
Name Type Description
url string The URL to redirect to.
status number <optional>
The XMLHttpRequest status.

remove(ajaxopt, response, statusopt)

Source:
Command to remove a chunk from the page.
Parameters:
Name Type Attributes Description
ajax Drupal.Ajax <optional>
Drupal.Ajax object created by Drupal.ajax.
response object The response from the Ajax request.
Properties
Name Type Attributes Description
selector string A jQuery selector string.
settings object <optional>
An optional array of settings that will be used.
status number <optional>
The XMLHttpRequest status.

restripe(ajaxopt, response, statusopt)

Source:
Command to restripe a table.
Parameters:
Name Type Attributes Description
ajax Drupal.Ajax <optional>
Drupal.Ajax object created by Drupal.ajax.
response object The response from the Ajax request.
Properties
Name Type Description
selector string A jQuery selector string.
status number <optional>
The XMLHttpRequest status.

settings(ajaxopt, response, statusopt)

Source:
Command to set the settings used for other commands in this response. This method will also remove expired `drupalSettings.ajax` settings.
Parameters:
Name Type Attributes Description
ajax Drupal.Ajax <optional>
Drupal.Ajax object created by Drupal.ajax.
response object The response from the Ajax request.
Properties
Name Type Description
merge boolean Determines whether the additional settings should be merged to the global settings.
settings object Contains additional settings to add to the global settings.
status number <optional>
The XMLHttpRequest status.

update_build_id(ajaxopt, response, statusopt)

Source:
Command to update a form's build ID.
Parameters:
Name Type Attributes Description
ajax Drupal.Ajax <optional>
Drupal.Ajax object created by Drupal.ajax.
response object The response from the Ajax request.
Properties
Name Type Description
old string The old form build ID.
new string The new form build ID.
status number <optional>
The XMLHttpRequest status.

Type Definitions

commandDefinition

Source:
See:
Properties:
Name Type Attributes Description
command string
method string <optional>
selector string <optional>
data string <optional>
settings object <optional>
asterisk boolean <optional>
text string <optional>
title string <optional>
url string <optional>
argument object <optional>
name string <optional>
value string <optional>
old string <optional>
new string <optional>
merge boolean <optional>
args Array <optional>
Type:
  • object