Skip to main content
added 236 characters in body
Source Link
4uk4
  • 101.7k
  • 7
  • 173
  • 217

Still early rendering should be avoided whenever possible. Did you try to return the unrendered view in an ajax command?

  $view = views_embed_view('user_admin_people', 'page_1');
  $ajax_response->addCommand(new HtmlCommand('#wrapper', $view));

AllIf you use the unrendered build array all the things you've described in the question like reattaching drupal behaviors, js, and css should beare handled by the ajax implementation in drupal, on the server side when assembling the response and on the client side when processing the incoming json data.

For this to work ajax hasyou also need to be enabledenable the option "Use AJAX" in the view user_admin_people of course if you don't want, otherwise the "Filter" button to rebuildrebuilds the form on a new page, which then happens to be the admin page.

Did you try to return the unrendered view in an ajax command?

  $view = views_embed_view('user_admin_people', 'page_1');
  $ajax_response->addCommand(new HtmlCommand('#wrapper', $view));

All the things you've described in the question like reattaching drupal behaviors, js, and css should be handled by drupal.

For this to work ajax has to be enabled in the view user_admin_people of course if you don't want the "Filter" button to rebuild the form on a new page.

Still early rendering should be avoided whenever possible. Did you try to return the unrendered view in an ajax command?

  $view = views_embed_view('user_admin_people', 'page_1');
  $ajax_response->addCommand(new HtmlCommand('#wrapper', $view));

If you use the unrendered build array all the things you've described in the question like reattaching drupal behaviors, js, and css are handled by the ajax implementation in drupal, on the server side when assembling the response and on the client side when processing the incoming json data.

For this to work you also need to enable the option "Use AJAX" in the view user_admin_people, otherwise the "Filter" button rebuilds the form on a new page, which then happens to be the admin page.

Source Link
4uk4
  • 101.7k
  • 7
  • 173
  • 217

Did you try to return the unrendered view in an ajax command?

  $view = views_embed_view('user_admin_people', 'page_1');
  $ajax_response->addCommand(new HtmlCommand('#wrapper', $view));

All the things you've described in the question like reattaching drupal behaviors, js, and css should be handled by drupal.

For this to work ajax has to be enabled in the view user_admin_people of course if you don't want the "Filter" button to rebuild the form on a new page.