Active
Project:
Drupal core
Version:
main
Component:
views.module
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
21 Jun 2019 at 15:54 UTC
Updated:
21 Oct 2019 at 06:36 UTC
Jump to comment: Most recent
I load a view in a controller with ajax, like this example:
$views_block = views_embed_view('example_views', 'block_1', $arguments);
$views_render = [
'#theme' => 'custom_template',
'#custom_view' => $views_block,
];
$render_root = $this->renderer->renderRoot($views_render);
$response = new AjaxResponse();
$selector = '#example-id';
$replace = new ReplaceCommand($selector, $render_root);
$response->addCommand($replace);
return $response;
So the user can click on a button on the website and the view appears with ajax. This is working great so far.
But the ajax pager of the view isn't working. The page reloads and shows the ajax replacement on a white screen. No JS errors...
I discovered that the view pager href has the controller path, instead of the current page relative path... I guess thats wrong.
Question: Is this a bug or what can I do?
Comments
Comment #2
handkerchiefAnyone?
Comment #3
handkerchiefComment #4
handkerchiefThe second problem, the ajax for the loaded views is not working. But the use-ajax option is enabled. I tried also the Views::getView() function and the $view->setAjaxEnabled(TRUE) method bevor execute and rendering the view. No success.
How is it possible to load a view via ajax and not broke the ajax functionality for the view itself?
Comment #5
handkerchiefMaybe somone there will help me:
https://drupal.stackexchange.com/questions/287522/how-to-load-a-view-via...