You are here

class RefreshResponsive in Bootstrap Styles 1.0.x

AJAX command for invoking an arbitrary jQuery method.

The 'invoke' command will instruct the client to invoke the given jQuery method with the supplied data on the elements matched by the given selector. Intended for simple jQuery commands, such as attr(), addClass(), removeClass(), toggleClass(), etc.

Hierarchy

Expanded class hierarchy of RefreshResponsive

File

src/Ajax/RefreshResponsive.php, line 15

Namespace

Drupal\bootstrap_styles\Ajax
View source
class RefreshResponsive implements CommandInterface {

  /**
   * 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;

  /**
   * A jQuery method to invoke.
   *
   * @var string
   */
  protected $method;

  /**
   * An optional list of data to pass to the method.
   *
   * @var array
   */
  protected $data;

  /**
   * Constructs an RefreshResponsive object.
   *
   * @param string $selector
   *   A jQuery selector.
   * @param string $method
   *   The name of a jQuery method to invoke.
   * @param array $data
   *   An optional array of data to pass to the method.
   */
  public function __construct($selector, $method, array $data = []) {
    $this->selector = $selector;
    $this->method = $method;
    $this->data = $data;
  }

  /**
   * Implements Drupal\Core\Ajax\CommandInterface:render().
   */
  public function render() {
    return [
      'command' => 'bs_refresh_responsive',
      'selector' => $this->selector,
      'method' => NULL,
      'data' => $this->data,
    ];
  }

}

Members

Namesort descending Modifiers Type Description Overrides
RefreshResponsive::$data protected property An optional list of data to pass to the method.
RefreshResponsive::$method protected property A jQuery method to invoke.
RefreshResponsive::$selector protected property A CSS selector string.
RefreshResponsive::render public function Implements Drupal\Core\Ajax\CommandInterface:render(). Overrides CommandInterface::render
RefreshResponsive::__construct public function Constructs an RefreshResponsive object.