我想将我的提示框更改为Sweet Alert2(https://sweetalert2.github.io/)。单击确认警报窗口上的“确定”按钮后,似乎没有发生任何事情。我似乎无法弄清楚什么是错的或如何解决问题。我的代码如下:
HTML:
<a href="functionalities/removeIncoming.php?incId=<?php echo $incID; ?>">
<button type="button" class="btn btn-default" id="delBtn" onclick="validateRemove(event);">
<span class="glyphicon glyphicon-book" aria-hidden="true"></span>
</button>
</a>
使用Javascript:
function validateRemove(e) {
e.preventDefault();
swal({
title: "Are you sure you want to archive this entry?",
type: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Yes',
cancelButtonText: "No"
}).then(function () {
swal(
'Archived',
'Your file has been Archived.',
'success'
)
})
}
答案 0 :(得分:3)
onclick="confirm1();"
function confirm1()
{
swal({
title: 'Are you sure?',
text: "You won't be able to revert this!",
type: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Yes, delete it!',
cancelButtonText: 'No, cancel!',
confirmButtonClass: 'btn btn-success',
cancelButtonClass: 'btn btn-danger',
buttonsStyling: false
}).then(function () {
swal(
'Deleted!',
'Your file has been deleted.',
'success'
)
//success method
}, function (dismiss) {
// dismiss can be 'cancel', 'overlay',
// 'close', and 'timer'
if (dismiss === 'cancel') {
swal(
'Cancelled',
'Your imaginary file is safe :)',
'error'
)
}
})
}