Rails UJS:使用“'ajax:before'"阻止事件传播 [英] Rails UJS: Preventing the event from propagating using "'ajax:before'"

查看:109
本文介绍了Rails UJS:使用“'ajax:before'"阻止事件传播的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对ajax:before在使用时的工作方式感到困惑:jquery-ujs/rails.js

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

1)它是否在ajax中等待任何给定的功能:完成之前,然后继续?

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

2)如果某个条件失败,我如何在jQuery中完全取消该事件? (我似乎没有指向事件的指针)

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

推荐答案

我回答了自己的问题. ajax中的"return false":之前将取消操作

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

这篇关于Rails UJS:使用“'ajax:before'"阻止事件传播的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆