我的 SweetAlert 确认没有等待任何操作。确认框闪烁,然后将执行操作。怎么了?
<script type="text/javascript">
function confirmDelete() {
swal({
title: "Are you sure?",
text: "You will not be able to recover this imaginary file!",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Delete",
cancelButtonText: "Cancel",
closeOnConfirm: false,
closeOnCancel: false
});
}
</script>
<form onsubmit="confirmDelete()" action="index.php" method="post">
<button type="submit" name="delete">Delete</button>
</form>
这个也试过了。同样的问题...窗口只是闪烁并执行操作。
<script type="text/javascript">
function confirmDelete() {
swal({
title: "Are you sure?",
text: "You will not be able to recover this imaginary file!",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Delete",
cancelButtonText: "Cancel",
closeOnConfirm: false,
closeOnCancel: false
},
function(isConfirm) {
if (isConfirm) {
document.deleteForm.submit();
}
});
}
</script>
<form id="deleteForm" action="index.php" method="post">
<button onclick="confirmDelete()" type="input" name="delete">Delete</button>
</form>