Drupal 7 advanced ajax

46,127

Published on

Published in: Technology

Drupal 7 advanced ajax

  1. 1. Drupal 7 Advanced AJAX Tips and Tricks
  2. 2. Summary • Non-form related AJAX • Responding to an AJAX request • Bind AJAX behavior to a simple link • In more than one way • Modify this behavior via javascript • Modify the AJAX response via javascript • Use a custom response command • Perform AJAX on non-traditional events like a timer.
  3. 3. We are skipping #ajax • This is the basic usage • Plenty of examples in examples.module • Too tied to the form id and cache
  4. 4. Responding to an AJAX request
  5. 5. Drupal’s AJAX Commands • http://api.drupal.org/api/drupal/includes--ajax.inc/group/ajax_commands/7
  6. 6. Simplest Example • <a href="/aajax-example/simple/nojs" id="aajax-example-1" class="use-ajax">Simple example</a> • l(t('Simple example'), 'aajax- example/simple/nojs', array('attributes' => array('id' => 'aajax-example-1', 'class' => 'use- ajax')))
  7. 7. Second verse, same as the first <a href="/aajax-example/simple/nojs" id="aajax- example-2" class=“aajax-example use-ajax">Simple example 2</a>
  8. 8. Setting up the AJAX event • Use Drupal’s behavior • Bind to a DOM object • Fill in the element_settings • Register the Drupal.ajax object
  9. 9. Element Settings Also: • wrapper
  10. 10. Let’s see this again <a href="/aajax-example/simple/nojs" id="aajax- example-2" class=“aajax-example use-ajax">Simple example 2</a>
  11. 11. Manipulating the response
  12. 12. Custom AJAX Command Javascript side PHP Side
  13. 13. What about things that are not clicks?
  14. 14. Wrapping up • This framework can integrate into strong javascript applications. • Server can be used for storage, rendering and decision making. • Client can be more interactive. • Framework can add additional CSS and javascript to page automatically.
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×