开发者

Rails UJS: Preventing the event from propagating using 'ajax:before'

开发者 https://www.devze.com 2023-01-29 06:03 出处:网络
I am confused by how ajax:before works when using rails/jquery-ujs. Does it wait for any given function in the ajax:before to complete before proceeding?

I am confused by how ajax:before works when using rails/jquery-ujs.

  1. Does it wait for any given function in the ajax:before to complete before proceeding?

  2. How do I completely cancel the event in jQuery if it fails some condition? (I do not seem to have a pointer to the event)

--

Update: I tried this, which normally works, but not now. =|

.bind('ajax:before', function(evt){
    evt开发者_如何学运维.stopImmediatePropagation();
   } )
 //also tried preventDefault, stopPropagation, etc


I answered my own question. "return false" in the ajax:before will cancel the action

0

精彩评论

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

关注公众号