Drupal. Use AJAX to update view's content

ozke picture ozke · Jun 10, 2010 · Viewed 12.3k times · Source

I've created a view in Drupal that retrieves a list of nodes. The display of this view is a page and it works perfectly well. It does even allow me to filter its content by argument.

See the current's view configuration (click to enlarge):

alt text

I want to use AJAX to use the filter (by parameter) functionality without reloading the page. I've enabled the "Use AJAX" option but I am not sure on how to continue. Any ideas on how to do that?

By the way, I'm building my own theme (in case that changes anything).


Update: Basically, this view works when I browse through section/parameter1, section/parameter2... but I want to do the same with AJAX, without reloading the page. I hope is clearer now

Answer

Even though this probably has been solved by this time, the best "Drupalistic way" to do it is explained in this screencast:

http://seanbuscay.com/ajax-reader-demo

It is not that hard, and works either with views or rendering full nodes.

According to the author of the screencast (and I can ensure you it is all right), this are the steps to remember:

  1. Write a menu callback.
  2. Return Ajax formatted content in a page callback function.
  3. Format the links (add "no-js" & "user-ajax" to the that point to the menu callback.
  4. Make sure the "jquery.form.js" the "drupal.ajax" libraries are loaded in the page.