0
我想用SweetAlert替换我的“确认”删除。Rails Bootstrap确认删除使用Sweetalert
目前正常工作以正常警报对话框删除观察者。我不知道如何调用sweetalert.js。
对不起,如果这是一个愚蠢的问题。我很新!谢谢!
team.html.erb
<td>
<div class="btn-group">
<%= link_to "/members/observers/#{observation.id}", class: "btn btn-xs btn-danger", method: :delete, data: { confirm: "Are you sure?" } do %>
<i class="fa fa-times fa-fw" data-toggle="tooltip" data-placement="top" title="Remove Observer"></i>
<% end %>
</div>
</td>
sweetalert.js
swal({
title: "Are you sure?",
text: "You will not be able to recover this imaginary file!",
type: "warning",
showCancelButton: true,
confirmButtonClass: "btn-danger",
confirmButtonText: "Yes, delete it!",
cancelButtonText: "No, cancel plx!",
closeOnConfirm: false,
closeOnCancel: false
},
function(isConfirm) {
if (isConfirm) {
swal("Deleted!", "Your imaginary file has been deleted.", "success");
} else {
swal("Cancelled", "Your imaginary file is safe :)", "error");
}
});
我忘了提及sweetalert宝石安装,似乎工作正常。 – NU2Rails
更新。我现在通过向btn添加一个“sweet_delete”类来调用sweetalert.js。因此它会打开sweetalert提示符,但不管在警报中选择什么选项,它都会继续执行删除操作。 – NU2Rails