pass variable to jquery function

0

I need to manipulate the clicked button inside this function, how to pass the btn variable into it?

$('.btn_excluir').on('click', function () {
    btn = $(this);
    swal_confirm('Deseja realmente excluir o registro?', function (btn) {
        console.log(btn);
    });
});
    
asked by anonymous 08.11.2018 / 13:53

1 answer

0

swal_confirm is not the correct method to use SweetAlert , according to the documentation you need to perform a function only if the OK button is clicked as in the example below.

Example

swal({
    title: "Deseja deletar?",
    text: "Tem certeza que deseja deletar o registro?",
    icon: "warning",
    buttons: true,
    dangerMode: true,
})
.then((willDelete) => {
    if (willDelete) {
        /* Chama a sua função para deletar */
        swal("Seu registro foi deletado!", {
            icon: "success",
        });
    } else {
        swal("Seu registro não foi deletado!");
    }
});
    
08.11.2018 / 18:56