SweetAlert2 je krásna, responzívna, prispôsobiteľná a prístupná náhrada za JavaScript popup okná. Nahradí natívne alert(), confirm() a prompt() funkcie.
Príklady odoslania formulárov s SweetAlert2 potvrdením:
Swal.fire({
icon: 'success',
title: 'Úspech!',
text: 'Operácia bola úspešne dokončená.'
});
Swal.fire({
title: 'Naozaj zmazať?',
text: "Túto akciu nebude možné vrátiť späť!",
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#d33',
cancelButtonColor: '#3085d6',
confirmButtonText: 'Áno, zmazať!',
cancelButtonText: 'Zrušiť'
}).then((result) => {
if (result.isConfirmed) {
// Perform deletion
}
});
const Toast = Swal.mixin({
toast: true,
position: 'top-end',
showConfirmButton: false,
timer: 3000,
timerProgressBar: true
});
Toast.fire({
icon: 'success',
title: 'Uložené úspešne'
});