[development] groking ajax callbacks
Earl Miles
merlin at logrus.com
Thu Dec 27 22:46:52 UTC 2007
Augustin (Beginner) wrote:
> url: Drupal.settings.book.formCallback +'/'+ $('#'+
> Drupal.settings.book.formId +' input[name=form_build_id]').val()
> +'/'+ $('#edit-book-bid').val(),
The part that you're not seeing is that there are 'settings' that are
set via inline javascript and there's a Drupal-side API to make this easy:
drupal_add_js($some_array, 'setting');
So if: $some_array = array('book' => array('formCallback' => 'book/js'));
That covers the first part of it.
The it pulls the formId out of the settings and uses jQuery to find the
form_build_id input in that form and take it's value, and after that
you've got the book id from #edit-book-bid.
Search book.module for drupal_add_js and look for the 'setting' call. I
think it'll be more clear after that.
More information about the development
mailing list