Rails UJS确认框取消按钮回调 [英] Rails UJS confirm box cancel button callback
本文介绍了Rails UJS确认框取消按钮回调的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用Rails jquery ujs 在我的应用程序中处理ajax.另外,我正在使用confirm
选项来销毁任何记录.
在我当前的设置中,点击data-remote=true
链接后,我已经连接了一个加载叠加屏幕.
I am using Rails jquery ujs for handling ajax within my app. Also I am using a the confirm
option for destroying any records.
As my current setup, I have hooked up a loading overlay screen on click of data-remote=true
link.
我想知道的是:当用户单击确认框上的cancel
并可以关闭加载程序覆盖时,是否可以挂起回调事件.
All I wanted to know is: Is there a way I can hook a callback event when a user clicks cancel
on the confirm box and I can close the loader overlay.
推荐答案
是的,可以.传递响应对象.在CoffeeScript中.
Yes, you can. Pass in the response object. In CoffeeScript.
$('selector').on 'confirm:complete', (e, response) ->
if response
# User confirmed
else
# User cancelled.
在Java语言中:
$('selector').on('confirm:complete', function(e, response) {
if(response) {
// User confirmed
}
else {
// User cancelled.
}
});
这篇关于Rails UJS确认框取消按钮回调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文