diff --git a/core/modules/views/lib/Drupal/views/Controller/ViewAjaxController.php b/core/modules/views/lib/Drupal/views/Controller/ViewAjaxController.php index 725a031..4d194d0 100644 --- a/core/modules/views/lib/Drupal/views/Controller/ViewAjaxController.php +++ b/core/modules/views/lib/Drupal/views/Controller/ViewAjaxController.php @@ -7,10 +7,12 @@ namespace Drupal\views\Controller; +use Drupal\Component\Utility\String; use Drupal\Component\Utility\Url; use Drupal\Core\Ajax\ReplaceCommand; use Drupal\Core\DependencyInjection\ContainerInjectionInterface; use Drupal\Core\Entity\EntityStorageControllerInterface; +use Drupal\Core\Ajax\SettingsCommand; use Drupal\views\Ajax\ScrollTopCommand; use Drupal\views\Ajax\ViewAjaxResponse; use Drupal\views\ViewExecutableFactory; @@ -131,6 +133,32 @@ public function ajaxView(Request $request) { $view->dom_id = $dom_id; $preview = $view->preview($display_id, $args); + + // If using AJAX, send identifying data about this view. + if ($view->ajaxEnabled() && empty($view->is_attachment) && empty($view->live_preview)) { + $settings = array( + 'views' => array( + 'ajax_path' => url('views/ajax'), + 'ajaxViews' => array( + 'views_dom_id:' . $dom_id => array( + 'view_name' => $name, + 'view_display_id' => $display_id, + 'view_args' => String::checkPlain(implode('/', $args)), + 'view_path' => String::checkPlain(current_path()), + 'view_base_path' => $path, + 'view_dom_id' => $dom_id, + // // To fit multiple views on a page, the programmer may have + // // overridden the display's pager_element. + 'pager_element' => $pager_element, + ), + ), + ), + ); + //$response->addCommand(new SettingsCommand($settings, TRUE)); + $view->element['#attached']['js'][] = array('type' => 'setting', 'data' => $settings); + $view->element['#attached']['library'][] = array('views', 'views.ajax'); + } + $response->addCommand(new ReplaceCommand(".view-dom-id-$dom_id", $this->drupalRender($preview))); return $response; } diff --git a/core/modules/views/views.theme.inc b/core/modules/views/views.theme.inc index 400fcf2..6fc1469 100644 --- a/core/modules/views/views.theme.inc +++ b/core/modules/views/views.theme.inc @@ -106,30 +106,6 @@ function template_preprocess_views_view(&$variables) { $variables['attributes']['class'][] = 'view-dom-id-' . $variables['dom_id']; } - // If using AJAX, send identifying data about this view. - if ($view->ajaxEnabled() && empty($view->is_attachment) && empty($view->live_preview)) { - $settings = array( - 'views' => array( - 'ajax_path' => url('views/ajax'), - 'ajaxViews' => array( - 'views_dom_id:' . $variables['dom_id'] => array( - 'view_name' => $view->storage->id(), - 'view_display_id' => $view->current_display, - 'view_args' => String::checkPlain(implode('/', $view->args)), - 'view_path' => String::checkPlain(current_path()), - 'view_base_path' => $view->getPath(), - 'view_dom_id' => $variables['dom_id'], - // To fit multiple views on a page, the programmer may have - // overridden the display's pager_element. - 'pager_element' => isset($view->pager) ? $view->pager->getPagerId() : 0, - ), - ), - ), - ); - $view->element['#attached']['js'][] = array('type' => 'setting', 'data' => $settings); - $view->element['#attached']['library'][] = array('views', 'views.ajax'); - } - // If form fields were found in the view, reformat the view output as a form. if ($view->hasFormElements()) { // Copy the rows so as not to modify them by reference when rendering.