Class: AjaxCommands

Drupal.AjaxCommands()

new AjaxCommands()

Provide a series of commands that the client will perform.

Source:

Methods

add_css(ajaxopt, response, statusopt)

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.

Source:

alert(ajaxopt, response, statusopt)

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.

Source:

announce(ajaxopt, response)

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.

Source:

changed(ajaxopt, response, statusopt)

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 bool <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.

Source:

closeDialog(ajaxopt, response, statusopt)

Command to close a dialog.

If no selector is given, it defaults to trying to close the modal.

Parameters:
Name Type Attributes Description
ajax Drupal.Ajax <optional>

The ajax object.

response object

Object holding the server response.

Properties
Name Type Description
selector string

The selector of the dialog.

persist bool

Whether to persist the dialog element or not.

status number <optional>

The HTTP status code.

Source:

css(ajaxopt, response, statusopt)

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.

Source:

data(ajaxopt, response, statusopt)

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.

Source:

editorDialogSave(ajaxopt, response, statusopt)

Command to save the contents of an editor-provided modal.

This command does not close the open modal. It should be followed by a call to Drupal.AjaxCommands.prototype.closeDialog. Editors that are integrated with dialogs must independently listen for an editor:dialogsave event to save the changes into the contents of their interface.

Parameters:
Name Type Attributes Description
ajax Drupal.Ajax <optional>

The Drupal.Ajax object.

response object

The server response from the ajax request.

Properties
Name Type Description
values Array

The values that were saved.

status number <optional>

The status code from the ajax request.

Source:
Fires:
  • event:editor:dialogsave

insert(ajax, response)

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>

A optional jQuery selector string.

settings object <optional>

An optional array of settings that will be used.

Source:

invoke(ajaxopt, response, statusopt)

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.

Source:

jsAjaxTestCommand(ajaxopt, response)

Test Ajax command.

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.

Source:

message(ajaxopt, response)

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 bool

If true, clear previous messages.

Source:

openDialog(ajax, response, statusopt) → {bool|undefined}

Command to open a dialog.

Parameters:
Name Type Attributes Description
ajax Drupal.Ajax

The Drupal Ajax object.

response object

Object holding the server response.

status number <optional>

The HTTP status code.

Source:
Returns:

Returns false if there was no selector property in the response object.

Type
bool | undefined

redirect(ajaxopt, response, statusopt)

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.

Source:

remove(ajaxopt, response, statusopt)

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.

Source:

restripe(ajaxopt, response, statusopt)

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.

Source:

setDialogOption(ajaxopt, response, statusopt)

Command to set a dialog property.

JQuery UI specific way of setting dialog options.

Parameters:
Name Type Attributes Description
ajax Drupal.Ajax <optional>

The Drupal Ajax object.

response object

Object holding the server response.

Properties
Name Type Description
selector string

Selector for the dialog element.

optionsName string

Name of a key to set.

optionValue string

Value to set.

status number <optional>

The HTTP status code.

Source:

settings(ajaxopt, response, statusopt)

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 bool

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.

Source:

setToolbarSubtrees(ajax, response, statusopt)

Ajax command to set the toolbar subtrees.

Parameters:
Name Type Attributes Description
ajax Drupal.Ajax

Drupal.Ajax object created by Drupal.ajax.

response object

JSON response from the Ajax request.

status number <optional>

XMLHttpRequest status.

Source:

update_build_id(ajaxopt, response, statusopt)

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.

Source:

updateMediaLibrarySelection(ajaxopt, response, statusopt)

Command to update the current media library selection.

Parameters:
Name Type Attributes Description
ajax Drupal.Ajax <optional>

The Drupal Ajax object.

response object

Object holding the server response.

status number <optional>

The HTTP status code.

Source:

viewsHighlight(ajaxopt, response, statusopt)

Ajax command for highlighting elements.

Parameters:
Name Type Attributes Description
ajax Drupal.Ajax <optional>

An Ajax object.

response object

The Ajax response.

Properties
Name Type Description
selector string

The selector in question.

status number <optional>

The HTTP status code.

Source:

viewsReplaceTitle(ajaxopt, response, statusopt)

Ajax command to replace the title of a page.

Parameters:
Name Type Attributes Description
ajax Drupal.Ajax <optional>

An Ajax object.

response object

The Ajax response.

Properties
Name Type Description
siteName string

The site name.

title string

The new page title.

status number <optional>

The HTTP status code.

Source:

viewsScrollTop(ajaxopt, response)

Views scroll to top ajax command.

Parameters:
Name Type Attributes Description
ajax Drupal.Ajax <optional>

A Drupal.ajax object.

response object

Ajax response.

Properties
Name Type Description
selector string

Selector to use.

Source:

viewsSetForm(ajaxopt, response, statusopt)

Ajax command to set the form submit action in the views modal edit form.

Parameters:
Name Type Attributes Description
ajax Drupal.Ajax <optional>

An Ajax object.

response object

The Ajax response. Contains .url

status string <optional>

The XHR status code?

Source:

viewsShowButtons(ajaxopt, response, statusopt)

Ajax command to show certain buttons in the views edit form.

Parameters:
Name Type Attributes Description
ajax Drupal.Ajax <optional>

An Ajax object.

response object

The Ajax response.

Properties
Name Type Description
changed bool

Whether the state changed for the buttons or not.

status number <optional>

The HTTP status code.

Source:

viewsTriggerPreview(ajaxopt, responseopt, statusopt)

Ajax command for triggering preview.

Parameters:
Name Type Attributes Description
ajax Drupal.Ajax <optional>

An Ajax object.

response object <optional>

The Ajax response.

status number <optional>

The HTTP status code.

Source:

Type Definitions

commandDefinition

Type:
  • object
Properties:
Name Type Attributes Description
command string
method string <optional>
selector string <optional>
data string <optional>
settings object <optional>
asterisk bool <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 bool <optional>
args Array <optional>
Source:
See: