I want to replace my project's confirms with SweetAlert2 dialogs but I'm having a problem handling cancel. I want that when clicking on a checkbox it shows a confirmation dialog and that if the user clicks on the cancel button the checkbox does not remain selected.
My code:
$(element).click(function (e) {
swal({
title: 'Seleccionado',
text: "¿Está seguro que desea seleccionarlo?",
type: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Si',
cancelButtonText: 'No'
}).then((result) => {
if (result.value) {
guardar(true);
} else {
return false;
}
});
});
For some reason when you click "No" it executes what you put in the else but the checkbox remains selected.
Any idea how to fix it?