1

我在我的视图中有 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()

现在我需要添加一个确认弹出窗口“您确定要删除这些帖子吗?” 当我单击删除按钮时..有关如何将其嵌入此代码的任何帮助?

4

1 回答 1

0

in your delete click function:

$("#delete").click ->
  if window.confirm("are you sure?)
    target = " delete "
    $("#needs_form").attr "action", target
    $("#needs_form").submit()
于 2012-05-17T04:58:26.737 回答