我有以下rails按钮:
<%=
link_to "Remove Product", product_path(product),
remote: true,
method: :delete,
data: { confirm: 'Are you sure you want to delete this product?' }
%>我使用rails-ujs显示confirm()对话框;是否有一种简单的方法可以用javascript获取确认答案?
发布于 2014-12-12 10:59:11
有一个confirm:complete回调;据我所见,这是没有记录的,我是通过从源头看找到的。
这将在confirm()调用之后立即执行:
$(document).on 'confirm:complete', (e, answer) ->
alert "Your answer was: #{answer}"
return true # You can still cancel by returning false here发布于 2014-12-12 11:00:48
您可以处理onclick事件,并使用以下方法:
if (confirm("Say hello?")) {
alert("hello!");
....
} else {
.....
alert("another")
}https://stackoverflow.com/questions/27442061
复制相似问题