RemoveCommand.php 981 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace Drupal\Core\Ajax;
  3. /**
  4. * AJAX command for calling the jQuery remove() method.
  5. *
  6. * The 'remove' command instructs the client to use jQuery's remove() method
  7. * to remove each of elements matched by the given selector, and everything
  8. * within them.
  9. *
  10. * This command is implemented by Drupal.AjaxCommands.prototype.remove()
  11. * defined in misc/ajax.js.
  12. *
  13. * @see http://docs.jquery.com/Manipulation/remove#expr
  14. *
  15. * @ingroup ajax
  16. */
  17. class RemoveCommand implements CommandInterface {
  18. /**
  19. * The CSS selector for the element(s) to be removed.
  20. *
  21. * @var string
  22. */
  23. protected $selector;
  24. /**
  25. * Constructs a RemoveCommand object.
  26. *
  27. * @param string $selector
  28. */
  29. public function __construct($selector) {
  30. $this->selector = $selector;
  31. }
  32. /**
  33. * Implements Drupal\Core\Ajax\CommandInterface:render().
  34. */
  35. public function render() {
  36. return [
  37. 'command' => 'remove',
  38. 'selector' => $this->selector,
  39. ];
  40. }
  41. }