class ReplaceCommand

AJAX command for calling the jQuery replace() method.

The 'insert/replaceWith' command instructs the client to use jQuery's replaceWith() method to replace each element matched matched by the given selector with the given HTML.

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

See jQuery replaceWith command

Hierarchy

Expanded class hierarchy of ReplaceCommand

2 files declare their use of ReplaceCommand
AjaxCommandsUnitTest.php in drupal/core/modules/system/lib/Drupal/system/Tests/Ajax/AjaxCommandsUnitTest.php
Definition of Drupal\system\Tests\Ajax\AjaxCommandsUnitTest.
file.module in drupal/core/modules/file/file.module
Defines a "managed_file" Form API field and a "file" field for Field module.

File

drupal/core/lib/Drupal/Core/Ajax/ReplaceCommand.php, line 24
Definition of Drupal\Core\Ajax\ReplaceCommand.

Namespace

Drupal\Core\Ajax
View source
class ReplaceCommand extends InsertCommand {

  /**
   * Implements Drupal\Core\Ajax\CommandInterface:render().
   */
  public function render() {
    return array(
      'command' => 'insert',
      'method' => 'replaceWith',
      'selector' => $this->selector,
      'data' => $this->html,
      'settings' => $this->settings,
    );
  }

}

Members

Namesort descending Modifiers Type Description Overrides
InsertCommand::$html protected property The HTML content that will replace the matched element(s).
InsertCommand::$selector protected property A CSS selector string.
InsertCommand::$settings protected property A settings array to be passed to any any attached JavaScript behavior.
InsertCommand::__construct public function Constructs an InsertCommand object.
ReplaceCommand::render public function Implements Drupal\Core\Ajax\CommandInterface:render(). Overrides InsertCommand::render