[support] AJAX

Fred Jones fredthejonester at gmail.com
Wed Oct 23 11:22:17 UTC 2013


> perhaps you could find one "on point" web page with Google and help me out.

No problem.

> I have a view which produces a page of links to content.  When the user
> clicks the link, I want to display an unadorned, overlaying, modal <DIV> of
> the target.  Imagine, for example, that the view produces a list of
> drawings, then I want to display the selected drawing without any real
> estate consumed by Drupal navigation or block regions.

This is actually what Colorbox already does. Probably that's all you need:

https://drupal.org/project/colorbox

If not, Google for "drupal ajax" and you will find the third result in
Google is an EXAMPLE of how to do it in Drupal, right on the Drupal
API site:

https://api.drupal.org/api/examples/ajax_example!ajax_example.module/group/ajax_example/7

> More specifically, how does 'class="use-ajax" ' do this magic?  I have to
> assume there is an onClick event handler hiding somewhere above me in the
> DOM looking for the class "use-ajax".  Where is this event listener
> attached? How does it become attached?  Where is the source, so I can see
> both the event handler and the attachment?

To understand the basics of Ajax if you prefer to do it yourself,
start with a tutorial. Here's one I found on Google:

http://www.w3schools.com/php/php_ajax_intro.asp

> Finally, how do I register my callback function which will operate on the
> returned JSON, which is a complicated question because I need an example of
> what I need to write, where I need to put it, and how I tell Drupal that it
> is there.

Google for "register ajax callback" and the first result is:

http://api.jquery.com/ajaxComplete/

Presuming that you already know that Drupal ships with and encourages
use of jQuery, this is all you need.

Good luck.


More information about the support mailing list