开发者

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜