I have an AJAX form which is validated by AJAX callback function. Everything is done using Drupal API. But I don't want to use standard mechanism of appending/prepending/replacing of DOM elements when callback happens. How to catch that AJAX response and react on it with my custom function?
Asked
Active
Viewed 2,155 times
1 Answers
2
You can try defining a behavior. In many situations, including an AJAX request, Drupal will call to "attachBehaviors" that will trigger your behavior too:
Drupal.behaviors.mybehavior = {
attach: function (context, settings) {
console.log(context);
}
};
You must check and inspect context to know if it's the right context what are you looking for

corbacho
- 8,762
- 1
- 26
- 23
-
1Thank you, that's what I needed. I also stumbled upon another good explanation: http://stackoverflow.com/questions/6604687/how-to-onclick-trigger-a-non-native-jquery-plugins-action – Maxim Jul 14 '11 at 06:01