public function AddJsCommand::__construct in Drupal 10
Constructs an AddJsCommand.
Parameters
array $scripts: An array containing the attributes of the 'script' tags to be added to the page. i.e. `['src' => 'someURL', 'defer' => TRUE]` becomes `<script src="someURL" defer>`.
string $selector: A CSS selector of the element where the script tags will be appended.
File
- core/
lib/ Drupal/ Core/ Ajax/ AddJsCommand.php, line 45
Class
- AddJsCommand
- An AJAX command for adding JS to the page via AJAX.
Namespace
Drupal\Core\AjaxCode
public function __construct(array $scripts, string $selector = 'body') {
$this->scripts = $scripts;
$this->selector = $selector;
}