2
Link
<a onClick="enviaDivida()" href="{{ route("admin.dividas.edit",$divida->id)}}"
class="btn btn-sm btn-clean btn-icon btn-icon-md" title="Enviar">
<i class="la la-send"></i> </a>
Script:
function enviaDivida(){
const swalWithBootstrapButtons = Swal.mixin({
customClass: {
confirmButton: 'btn btn-success',
cancelButton: 'btn btn-danger'
},
buttonsStyling: false
})
swalWithBootstrapButtons.fire({
title: 'Deseja realmente enviar os dados para a Central da Cobrar Simples?',
text: "Atenção os dados serão enviados imediatamente!",
type: 'warning',
showCancelButton: true,
confirmButtonText: 'Sim, enviar dados da dívida!',
cancelButtonText: 'Não, cancelar!',
reverseButtons: true
}).then((result) => {
if (result.value) {
swalWithBootstrapButtons.fire(
'Cancelar!',
'Your file has been deleted.',
'success'
)
} else if (
/* Read more about handling dismissals below */
result.dismiss === Swal.DismissReason.cancel
) {
swalWithBootstrapButtons.fire(
'Processo Cancelado',
'Nada ocorreu',
'info'
)
}
})
}
As well as "run a link"?
– Sam
Type in the URL have
href="/exluir/cliente/3"
, when I open theSweetAlert
I want to put it in the part where you confirm the deletion so you can run the delete– André Cabral
Okay, but you want to redirect the page to the URL that is in href?
– Sam
That, at the url inside href
– André Cabral
If you redirect when confirming, it makes no sense to open another alert confirming that something happened, because the page will be redirected and the user won’t even be able to read the alert.
– Sam
Come on, when you click on the link containing the url
href="/exluir/cliente/3"
Swal will open, right? At this point the user will decide whether to cancel or confirm the "delete", whether to confirm is redirected.– André Cabral
Actually the term is not redirect, but rather the execution of the url that after this does the redirect by the backend controller.
– André Cabral