When you click on "Confirm
" or "Cancel
", they both trigger the function "isConfirm
". Interestingly, the "Cancel
" button does not close the alert as expected. It appears to be clashing with the SweetAlert triggered in the confirmation function. Has anyone encountered this issue before?
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 please!",
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");
}
});
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="92e1e5f7f7e6f3fef7e0e6d2a3bca3bca1">[email protected]</a>/dist/sweetalert.css">
<script src="https://cdn.jsdelivr.net/npm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1a696d7f7f6e7b767f686e5a2b342b3429">[email protected]</a>/dist/sweetalert.min.js"></script>