Drupal.behaviors

I wasted several hours today trying to enable behaviors in a Drupal 5 site and just couldn't get it to work. Several other sites on the same server had it working. All the instructions I found on the web were straight forward and correlated with what I am doing.

Finally I figured out that core drupal 5 does not have behavior functionality. The jstools module implements this feature, since everything magically worked as soon as I enabled that module.

Drupal.behaviors = Drupal.behaviors || {};

/**
* Attach registered behaviors.
*/
Drupal.attachBehaviors = function(context) {
  context = context || document;
  if (Drupal.jsEnabled && Drupal.behaviors) {
    // Execute all of them.
    jQuery.each(Drupal.behaviors, function() {
      this(context);
    });
  }
};

No votes yet