[support] AJAX

Chris Miller cjm at tryx.org
Tue Oct 22 20:10:52 UTC 2013


Hi Folks, 

This is a biggie... 

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. I know this is a job for AJAX, and I need someone to just fill in a gap or two. Here's what I think I know: 

In response to the user's click on the link, through the magic of 'class="use-ajax" ', Drupal will make an AJAX call for the requested content, wait on the promise, and finally return JSON encoded content to some function that I provide so that I can display the returned content in a <DIV> constructed specially for the circumstance. I see the example, but I can't quite follow it. 

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? 

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. 

Thanks for the help, 

Chris. 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/support/attachments/20131022/6062f17f/attachment.html 


More information about the support mailing list