class InsertCommand implements CommandInterface, CommandWithAttachedAssetsInterface (View source)

Generic AJAX command for inserting content.

This command instructs the client to insert the given HTML using whichever jQuery DOM manipulation method has been specified in the #ajax['method'] variable of the element that triggered the request.

This command is implemented by Drupal.AjaxCommands.prototype.insert() defined in misc/ajax.js.

Traits

Trait for Ajax commands that render content and attach assets.

Properties

protected AttachedAssets $attachedAssets

The attached assets for this Ajax command.

from  CommandWithAttachedAssetsTrait
protected string $selector

A CSS selector string.

protected string|array $content

The content for the matched element(s).

protected array $settings

A settings array to be passed to any attached JavaScript behavior.

Methods

getRenderedContent()

Processes the content for output.

getAttachedAssets()

Gets the attached assets.

__construct(string $selector, string|array $content, array $settings = NULL)

Constructs an InsertCommand object.

render()

Implements Drupal\Core\Ajax\CommandInterface:render().

Details

protected string|MarkupInterface getRenderedContent()

Processes the content for output.

If content is a render array, it may contain attached assets to be processed.

Return Value

string|MarkupInterface

HTML rendered content.

AttachedAssets|null getAttachedAssets()

Gets the attached assets.

Return Value

AttachedAssets|null

The attached assets for this command.

__construct(string $selector, string|array $content, array $settings = NULL)

Constructs an InsertCommand object.

Parameters

string $selector

A CSS selector.

string|array $content

The content that will be inserted in the matched element(s), either a render array or an HTML string.

array $settings

An array of JavaScript settings to be passed to any attached behaviors.

render()

Implements Drupal\Core\Ajax\CommandInterface:render().