Rails UJS:使用“ajax:before"防止事件传播

编程入门 行业动态 更新时间:2024-10-27 14:35:01
本文介绍了Rails UJS:使用“ajax:before"防止事件传播的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

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

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

它是否等待 ajax:before 中的任何给定函数完成后再继续?

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

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

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:before 中的 "return false" 将取消操作

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

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

更多推荐

[db:关键词]

本文发布于:2023-04-23 08:26:10,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1038493.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:事件   UJS   Rails   quot   ajax

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!