[development] groking ajax callbacks

Augustin (Beginner) drupal.beginner at wechange.org
Thu Dec 27 14:16:34 UTC 2007


See my message to the documentation list about where to document 
everything ajax, ahax, js, and jquery. 

Right now, I am trying hard to understand book.js and ... I just don't 
get it.

In book.js, there is an ajax call:

    url: Drupal.settings.book.formCallback +'/'+ $('#'+ 
Drupal.settings.book.formId +' input[name=form_build_id]').val() 
+'/'+ $('#edit-book-bid').val(),
    dataType: 'json',
    success: function(data) {
      // Insert the new select, and remove the progress bar.

in book_menu(), there is a menu callback, which I guess is the 
callback used by the js above:

  $items['book/js/form'] = array(
    'page callback' => 'book_form_update',
    'access arguments' => array('access content'),
    'type' => MENU_CALLBACK,
    'file' => 'book.pages.inc',

But everything javascript and ajax being completely undocumented, I am 
having a hard time to connect the two together, even by looking at 
drupal.js, looking at the big documentation block above 
drupal_add_js() (in common.inc), which I don't understand at all (I 
told you it was too early to change my handle!!) 

How does this...

    url: Drupal.settings.book.formCallback +'/'+ $('#'+ 
Drupal.settings.book.formId +' input[name=form_build_id]').val()+'/'+ 

...lead to the book/js/form callback???

I sense it is connected to Drupal.attachBehaviors (in drupal.js) and 
Drupal.behaviors.bookSelect (book.js), but I don't know how.

As I always do, if you tell me both the answer and where to document 
this, I'll have a go at starting a documentation.

Thanks and blessings,


More information about the development mailing list