You are here

protected function ExposedFilterViewsAjaxGetTest::addAjaxCompleteHandler in Views Ajax Get 8

Same name and namespace in other branches
  1. 2.0.x tests/src/FunctionalJavascript/ExposedFilterViewsAjaxGetTest.php \Drupal\Tests\views_ajax_get\FunctionalJavascript\ExposedFilterViewsAjaxGetTest::addAjaxCompleteHandler()

Add an AJAX event handler to get the AJAX response information.

1 call to ExposedFilterViewsAjaxGetTest::addAjaxCompleteHandler()
ExposedFilterViewsAjaxGetTest::testExposedFiltering in tests/src/FunctionalJavascript/ExposedFilterViewsAjaxGetTest.php
Tests if exposed filtering via AJAX works for the "Content" View.

File

tests/src/FunctionalJavascript/ExposedFilterViewsAjaxGetTest.php, line 101

Class

ExposedFilterViewsAjaxGetTest
Tests basic AJAX functionality of Views exposed forms using GET requests.

Namespace

Drupal\Tests\views_ajax_get\FunctionalJavascript

Code

protected function addAjaxCompleteHandler() {
  $javascript = <<<JS
    (function(\$, drupalSettings) {
      \$(document).on('ajaxComplete', function(event, xhr, settings) {
        drupalSettings.viewsAjaxGetMethod = settings.type;
        drupalSettings.viewsAjaxGetCacheHeader = xhr.getResponseHeader('X-Drupal-Cache');
      });
    }(jQuery, drupalSettings));
JS;
  $this
    ->getSession()
    ->executeScript($javascript);
}