Drupal: How to bind a custom jQuery function to a certain AJAX response?
I have an AJAX form which is validated by AJAX callback function. Everything is done using Drupal API. But I don't want t开发者_如何学Pythono 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?
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
精彩评论