Interviewer: Drupal 8 is amazing … isn’t it?
Angry me: No, it’s not!
One of the problems we have spent lot’s of energies on is related to Drupal 8 views.
As you probably know the contrib module views has been integrated as a core module in this version 8 of Drupal.
Eventough there’s a nice page with documentation on D8 views, as a Drupal developers we know we can not fully rely on it to get rid of problems.
But, what is happening?
For some reason, after hours, we have understand that even if you flag the checkbox to “use ajax” you are not able to get
in browser console and neither, of course, the ajax views behavior.
When you are invoking the view do not forget to invoke “preview” method too, because it is responsible to prepare the view as desired.
<?php // Getting a view. $view = Views::getView('view_name'); // Invoking preview to pre and post execute the view. $view->preview('view_display_type'); // Getting the view (WITH AJAX WORKING! YEAH!!) $sample_reception = $view->render(); ?>
We found no documentation on the web, so we assume this article will be useful for some Drupal information thirsty developer.
Thanks to Luca Rossi that achieved the solution.