Drupal's attach behaviours : react on all newly loaded content? I've got two different modules which in many ways work together. One of the things they work together on is that module A loads content via AJAX, and module B needs to attach event listeners to the content loaded.

However, it appears that when content is loaded via AJAX by module A, only the 'attach' function of Drupal.behaviours.a gets invoked, and not the 'attach' function of Drupal.behaviours.b. Both functions gets invoked on page load, but not on subsequent AJAX content loading.

// This runs every time module A loads new content.
Drupal.behaviors.a = {
  attach: function(context, settings) {
    alert('a:attach');
  }
}

// This only runs on page load, but never when module A loads new content.
Drupal.behaviors.b = {
  attach: function(context, settings) {
    alert('b:attach');
  }
}    


How do i make the 'attach' function of Drupal.behaviours.b run every time any module loads new content?
This, from the comments in misc/drupal.js, explains how it's supposed to work:


Drupal.attachBehaviors is added below to the jQuery ready event and so
runs on initial page load. Developers implementing AHAH/Ajax in their
solutions should also call this function after new page content has been
loaded, feeding in an element to be processed, in order to attach all
behaviors to the new content.