我正在为我的网络应用程序使用甜蜜警报。我遇到了类似问题的帖子,他们从来没有相应的答案。我想知道一旦用户确认,我将如何发布到动作结果方法。支持代码如下。求助。
swal({
title: "Are you sure?",
text: "You will not be able to recover this imaginary file!",
type: " warning ",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
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 ");
}
});
答案 0 :(得分:0)
我不确定你在哪里组建,但假设它的id是形式,那么下面的内容可能会让你开始:
swal({
title: "Are you sure?",
text: "You will not be able to recover this imaginary file!",
type: " warning ",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, delete it!",
cancelButtonText: " No, cancel plx!",
closeOnConfirm: false,
closeOnCancel: false
}, function(isConfirm) {
if (isConfirm) {
// once confirm, post your form
$("#form").submit();
} else {
swal("Cancelled", "Your imaginary file is safe: ) ", " error ");
}
});