class DataCommand
Same name and namespace in other branches
- 11.x core/lib/Drupal/Core/Ajax/DataCommand.php \Drupal\Core\Ajax\DataCommand
- 10 core/lib/Drupal/Core/Ajax/DataCommand.php \Drupal\Core\Ajax\DataCommand
- 9 core/lib/Drupal/Core/Ajax/DataCommand.php \Drupal\Core\Ajax\DataCommand
- 8.9.x core/lib/Drupal/Core/Ajax/DataCommand.php \Drupal\Core\Ajax\DataCommand
An AJAX command for implementing jQuery's data() method.
This instructs the client to attach the name=value pair of data to the selector via jQuery's data cache.
This command is implemented by Drupal.AjaxCommands.prototype.data() defined in misc/ajax.js.
Hierarchy
- class \Drupal\Core\Ajax\DataCommand implements \Drupal\Core\Ajax\CommandInterface
Expanded class hierarchy of DataCommand
Related topics
2 files declare their use of DataCommand
- AjaxCommandsTest.php in core/
tests/ Drupal/ Tests/ Core/ Ajax/ AjaxCommandsTest.php - Callbacks.php in core/
modules/ system/ tests/ modules/ ajax_forms_test/ src/ Callbacks.php
File
-
core/
lib/ Drupal/ Core/ Ajax/ DataCommand.php, line 16
Namespace
Drupal\Core\AjaxView source
class DataCommand implements CommandInterface {
/**
* Constructs a DataCommand object.
*
* @param string $selector
* A CSS selector for the elements to which the data will be attached.
* @param string $name
* The key of the data to be attached to elements matched by the selector.
* @param mixed $value
* The value of the data to be attached to elements matched by the selector.
*/
public function __construct(protected $selector, protected $name, protected $value) {
}
/**
* Implements Drupal\Core\Ajax\CommandInterface:render().
*/
public function render() {
return [
'command' => 'data',
'selector' => $this->selector,
'name' => $this->name,
'value' => $this->value,
];
}
}
Members
| Title Sort descending | Modifiers | Object type | Summary | Overriden Title |
|---|---|---|---|---|
| DataCommand::render | public | function | Implements Drupal\Core\Ajax\CommandInterface:render(). | Overrides CommandInterface::render |
| DataCommand::__construct | public | function | Constructs a DataCommand object. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.