ReplaceCommand.php 870 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace Drupal\Core\Ajax;
  3. /**
  4. * AJAX command for calling the jQuery replace() method.
  5. *
  6. * The 'insert/replaceWith' command instructs the client to use jQuery's
  7. * replaceWith() method to replace each element matched by the given selector
  8. * with the given HTML.
  9. *
  10. * This command is implemented by Drupal.AjaxCommands.prototype.insert()
  11. * defined in misc/ajax.js.
  12. *
  13. * See
  14. * @link http://docs.jquery.com/Manipulation/replaceWith#content jQuery replaceWith command @endlink
  15. *
  16. * @ingroup ajax
  17. */
  18. class ReplaceCommand extends InsertCommand {
  19. /**
  20. * Implements Drupal\Core\Ajax\CommandInterface:render().
  21. */
  22. public function render() {
  23. return [
  24. 'command' => 'insert',
  25. 'method' => 'replaceWith',
  26. 'selector' => $this->selector,
  27. 'data' => $this->getRenderedContent(),
  28. 'settings' => $this->settings,
  29. ];
  30. }
  31. }