Skip to main content
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
added 2 characters in body
Source Link
No Sssweat
  • 31.6k
  • 14
  • 55
  • 91

I have a view that is being rendered like this

$view = Views::getView('view_id');
$view->setDisplay('block_1');
$view->execute();
$render = $view->render(); 
$html = \Drupal::service('renderer')->render($render);

The $html variable is being returned in the build method of a Block

public function build() {
    return array(
      '#theme' => 'theme_template',
      '#view' => $html,
    );
  }

Then being outputted in the twig file {{ view }}{{ view }}

The view is being rendered but the pagination does not use ajax instead it reloads the page with the query string ?page=1

I have found a similar question but this is for drupal 7: Use ajax not working in views block displayed programmatically

Thank you in advance!

I have a view that is being rendered like this

$view = Views::getView('view_id');
$view->setDisplay('block_1');
$view->execute();
$render = $view->render(); 
$html = \Drupal::service('renderer')->render($render);

The $html variable is being returned in the build method of a Block

public function build() {
    return array(
      '#theme' => 'theme_template',
      '#view' => $html,
    );
  }

Then being outputted in the twig file {{ view }}

The view is being rendered but the pagination does not use ajax instead it reloads the page with the query string ?page=1

I have found a similar question but this is for drupal 7: Use ajax not working in views block displayed programmatically

Thank you in advance!

I have a view that is being rendered like this

$view = Views::getView('view_id');
$view->setDisplay('block_1');
$view->execute();
$render = $view->render(); 
$html = \Drupal::service('renderer')->render($render);

The $html variable is being returned in the build method of a Block

public function build() {
    return array(
      '#theme' => 'theme_template',
      '#view' => $html,
    );
  }

Then being outputted in the twig file {{ view }}

The view is being rendered but the pagination does not use ajax instead it reloads the page with the query string ?page=1

I have found a similar question but this is for drupal 7: Use ajax not working in views block displayed programmatically

Thank you in advance!

Source Link

Use AJAX not working when view is rendered programmatically

I have a view that is being rendered like this

$view = Views::getView('view_id');
$view->setDisplay('block_1');
$view->execute();
$render = $view->render(); 
$html = \Drupal::service('renderer')->render($render);

The $html variable is being returned in the build method of a Block

public function build() {
    return array(
      '#theme' => 'theme_template',
      '#view' => $html,
    );
  }

Then being outputted in the twig file {{ view }}

The view is being rendered but the pagination does not use ajax instead it reloads the page with the query string ?page=1

I have found a similar question but this is for drupal 7: Use ajax not working in views block displayed programmatically

Thank you in advance!