3 namespace Drupal\Core\Ajax;
6 * An AJAX command for implementing jQuery's data() method.
8 * This instructs the client to attach the name=value pair of data to the
9 * selector via jQuery's data cache.
11 * This command is implemented by Drupal.AjaxCommands.prototype.data() defined
16 class DataCommand implements CommandInterface {
19 * A CSS selector string for elements to which data will be attached.
21 * If the command is a response to a request from an #ajax form element then
22 * this value can be NULL.
29 * The key of the data attached to elements matched by the selector.
36 * The value of the data to be attached to elements matched by the selector.
38 * The data is not limited to strings; it can be any format.
45 * Constructs a DataCommand object.
47 * @param string $selector
48 * A CSS selector for the elements to which the data will be attached.
50 * The key of the data to be attached to elements matched by the selector.
52 * The value of the data to be attached to elements matched by the selector.
54 public function __construct($selector, $name, $value) {
55 $this->selector = $selector;
57 $this->value = $value;
61 * Implements Drupal\Core\Ajax\CommandInterface:render().
63 public function render() {
67 'selector' => $this->selector,
68 'name' => $this->name,
69 'value' => $this->value,