The structure of Drupal.behaviors
is rather similar in Drupal 7 and Drupal 8. Where do attach()
and detach()
come from?
Thid code is from drupal.js , still wondering where attach method in this.attach is defined?
Drupal.attachBehaviors = function (context, settings) {
context = context || document;
settings = settings || Drupal.settings;
// Execute all of them.
$.each(Drupal.behaviors, function () {
if ($.isFunction(this.attach)) {
this.attach(context, settings);
}
});
};