Well, I have a problem... I'm using sweetalert.js
and I've been racking my brain to understand how theconfirm
swal("Are you sure?", {
dangerMode: true,
buttons: true,
});
I have a button delete
and what I want is that it first ask if you want to delete the record or not, and depending on which button you select, it does so or not. But I do not know how to do it. I read the documentation but it doesn't explain it.
They sweetalert2
have a more intuitive confirm function...
Swal.fire({
title: 'Do you want to save the changes?',
showDenyButton: true,
showCancelButton: true,
confirmButtonText: 'Save',
denyButtonText: `Don't save`,
}).then((result) => {
/* Read more about isConfirmed, isDenied below */
if (result.isConfirmed) {
(AQUI IRIA MI FUNCION ELIMINAR)
} else if (result.isDenied) {
(AQUI UNA ALERTA "TU REGISTRO ESTA A SALVO")
}
})
But I don't know how to do that with the sweetalert.js
help
Taken from the documentation :
It is practically identical to sweetalert2, you define the callback using
then
So with raw javascript, but you could as well use arrow functions like Israel told you.