我在视图中有4个按钮在coffescript中实现,这里是视图
%button#warn.button{:type => "submit"}
Warn
%button#ban.button{:type => "submit"}
Ban
%button#delete.button{:type => "submit"} ,
Delete
%button#hide.button{:type => "submit"}
Hide
在js.coffee文件中,这就是我写的
$(document).ready ->
$("#warn").click ->
target = "check_warned"
$("#needs_form").attr "action", target
$("#needs_form").submit()
$("#ban").click ->
target = "ban "
$("#needs_form").attr "action", target
$("#needs_form").submit()
$("#delete").click ->
target = " delete "
$("#needs_form").attr "action", target
$("#needs_form").submit()
$("#hide").click ->
target = " hide "
$("#needs_form").attr "action", target
$("#needs_form").submit()
现在我需要添加一个确认弹出窗口"您确定要删除这些帖子吗?"当我点击删除按钮..有关如何将其嵌入此代码的任何帮助?
答案 0 :(得分:0)
:
$("#delete").click ->
if window.confirm("are you sure?)
target = " delete "
$("#needs_form").attr "action", target
$("#needs_form").submit()