3 namespace Drupal\Core\Ajax;
6 * AJAX command for invoking an arbitrary jQuery method.
8 * The 'invoke' command will instruct the client to invoke the given jQuery
9 * method with the supplied arguments on the elements matched by the given
10 * selector. Intended for simple jQuery commands, such as attr(), addClass(),
11 * removeClass(), toggleClass(), etc.
13 * This command is implemented by Drupal.AjaxCommands.prototype.invoke()
14 * defined in misc/ajax.js.
18 class InvokeCommand implements CommandInterface {
21 * A CSS selector string.
23 * If the command is a response to a request from an #ajax form element then
24 * this value can be NULL.
31 * A jQuery method to invoke.
38 * An optional list of arguments to pass to the method.
45 * Constructs an InvokeCommand object.
47 * @param string $selector
49 * @param string $method
50 * The name of a jQuery method to invoke.
51 * @param array $arguments
52 * An optional array of arguments to pass to the method.
54 public function __construct($selector, $method, array $arguments = []) {
55 $this->selector = $selector;
56 $this->method = $method;
57 $this->arguments = $arguments;
61 * Implements Drupal\Core\Ajax\CommandInterface:render().
63 public function render() {
66 'command' => 'invoke',
67 'selector' => $this->selector,
68 'method' => $this->method,
69 'args' => $this->arguments,