删除确认对话框未显示

时间:2015-11-05 16:46:15

标签: javascript jquery ruby-on-rails confirm-dialog

我在用户个人资料页面中定义了一个link_to来删除该帐户。

var delete_path = $(this).attr('href');

$(".confirm").confirm({
text: "Are you sure you want to delete your account?",
title: "Confirmation required",

confirm: function(button) {
    alert("You have confirm!")
    window.location.href = delete_path;
},
cancel: function(button) {
     $(this).dialog("close");
},
confirmButton: "Yes I want to delete my account",
cancelButton: "No I want to go back",
post: true,
confirmButtonClass: "btn-danger",
cancelButtonClass: "btn-default",
dialogClass: "modal-dialog modal-lg" // Bootstrap classes for large modal});

Jquery代码位于javascripts / application.js中,如下所示:

{{1}}

实际上按钮功能正常,帐户已成功删除。但确认对话框没有显示出来。我是Jquery的新手。不知道是否遗漏了某些组件。

1 个答案:

答案 0 :(得分:0)

我建议您从

更改删除链接
= link_to "Delete My Account", user_path(@user), :method=>:delete, :confirm => "Are you sure to delete your account?"

= link_to "Delete My Account", user_path(@user), :method=>:delete, data: {:confirm => "Are you sure to delete your account?"}

删除记录前会显示确认对话框。