Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A gist to create confirmation js with sweet alert
// Add .delete-confirm class to your delete button or href
<script>
// Swal
$('.delete-confirm').on('click', function(e) {
var href = this;
e.preventDefault();
swal({
title: "Êtes-vous sûr?",
text: "Après suppression l'article ne sera plus accessible",
type: "warning",
showCancelButton: true,
confirmButtonColor: '#e74c3c',
cancelButtonText: "Non, annuler!",
confirmButtonText: "Oui, supprimer!",
closeOnConfirm: false,
closeOnCancel: false
},
function(isConfirm) {
if (isConfirm) {
window.location.href = href;
} else {
swal("Annulation", "Vous avez annuler la suppression :)", "success");
}
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment