class BeforeCommand extends InsertCommand (View source)

An AJAX command for calling the jQuery before() method.

The 'insert/before' command instructs the client to use jQuery's before() method to insert the given HTML content before each of elements matched by the given selector.

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.

from  InsertCommand
protected string|array $content

The content for the matched element(s).

from  InsertCommand
protected array $settings

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

from  InsertCommand

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().