1
When updating the library Sweetalert it stopped working, while debugging the error I saw that it had many modifications that made the version 1.x incompatible with the new version, so I would like help to transcribe my function deletarRegistro()
.
Function code with sweetalert 1.x
function deletarRegistro() {
if (id_row > 0) {
swal({
title: "Você tem certeza disso?",
text: "Uma vez deletado, não há como desfazer!",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Sim, delete isto!",
showLoaderOnConfirm: true,
closeOnConfirm: false
},
function () {
$.post('/api/tdocumentos/delete', {id: id_row})
.done(function () {
tbl_api.row('.info').remove().draw(false);
swal("Deletado!", "Seu registro foi deletado.", "success");
id_row = null;
formulario.reset();
$(tab_lista).click();
})
.fail(function (response) {
console.log(response.responseText);
swal("Erro!", response.responseText, "error");
})
;
})
;
} else {
tbl_dependentes.effect('shake');
return false;
}
}
The Sweetalert 2.0 documentation from this example:
swal({
title: "Are you sure?",
text: "Once deleted, you will not be able to recover this imaginary
file!",
icon: "warning",
buttons: true,
dangerMode: true,
})
.then((willDelete) => {
if (willDelete) {
swal("Poof! Your imaginary file has been deleted!", {
icon: "success",
});
} else {
swal("Your imaginary file is safe!");
}
});
Question: I would like to know how I can transcribe the function using predecessors, and know what the use of predecessors improves in function.
Why did you update? Watching the code saw no apparent improvements. Maybe something related to the internal code of sweetAlert2 itself?
– guastallaigor
@guastallaigor Yes, the structure of the code had to be changed because the Sweetalert component changed version and with that some things were discontinued, so I had to implement in this way that I replied.
– Jean Freitas