You are here

class JcarouselAppendCommand in jCarousel 8.5

Same name and namespace in other branches
  1. 8.4 src/Ajax/JcarouselAppendCommand.php \Drupal\jcarousel\Ajax\JcarouselAppendCommand

An AJAX command for adding jCarousel items dynamically.

This command is implemented by Drupal.AjaxCommands.prototype.jcarousel_append() defined in js/jcarousel.js.

Hierarchy

Expanded class hierarchy of JcarouselAppendCommand

See also

http://sorgalla.com/jcarousel/docs/reference/usage.html#manipulating-the...

1 file declares its use of JcarouselAppendCommand
JcarouselViewAjaxController.php in src/Controller/JcarouselViewAjaxController.php
Contains \Drupal\jcarousel\Controller\JcarouselViewAjaxController.

File

src/Ajax/JcarouselAppendCommand.php, line 23
Contains \Drupal\Core\Ajax\JcarouselAppendCommand.

Namespace

Drupal\jcarousel\Ajax
View source
class JcarouselAppendCommand implements CommandInterface, CommandWithAttachedAssetsInterface {
  use CommandWithAttachedAssetsTrait;

  /**
   * A CSS selector string.
   *
   * If the command is a response to a request from an #ajax form element then
   * this value can be NULL.
   *
   * @var string
   */
  protected $selector;

  /**
   * The content for the matched element(s).
   *
   * Either a render array or an HTML string.
   *
   * @var string|array
   */
  protected $content;

  /**
   * A settings array to be passed to any any attached JavaScript behavior.
   *
   * @var array
   */
  protected $settings;

  /**
   * Preload content flag.
   *
   * If the command is a response to a request from an #ajax form element then
   * this value can be NULL.
   *
   * @var bool
   */
  protected $stop_preload;

  /**
   * {@inheritdoc}
   */
  public function __construct($selector, $content, array $settings = NULL) {
    $this->selector = $selector;
    $this->content = $content;
    $this->settings = $settings;
  }

  /**
   * {@inheritdoc}
   */
  public function render() {
    return [
      'command' => 'jcarousel_append',
      'method' => 'append',
      'selector' => $this->selector,
      'data' => $this
        ->getRenderedContent(),
      'settings' => $this->settings,
    ];
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CommandWithAttachedAssetsTrait::$attachedAssets protected property The attached assets for this Ajax command.
CommandWithAttachedAssetsTrait::getAttachedAssets public function Gets the attached assets.
CommandWithAttachedAssetsTrait::getRenderedContent protected function Processes the content for output.
JcarouselAppendCommand::$content protected property The content for the matched element(s).
JcarouselAppendCommand::$selector protected property A CSS selector string.
JcarouselAppendCommand::$settings protected property A settings array to be passed to any any attached JavaScript behavior.
JcarouselAppendCommand::$stop_preload protected property Preload content flag.
JcarouselAppendCommand::render public function Return an array to be run through json_encode and sent to the client. Overrides CommandInterface::render
JcarouselAppendCommand::__construct public function