3
I need to do an exclusion confirmation modal.
In html
<a class="btn btn-primary" onclick="Confirmar(<?=$dados->id;?>)">Excluir</a>
Function
<script>
var base_url = '<?php echo base_url() ?>';
function Confirmar(id_registro) {
bootbox.confirm({
message: 'Confirma a exclusão do registro?',
callback: function (confirmacao) {
if (confirmacao) {
$.post(base_url + 'index.php/ProspectoCrmController/deletar',{
id_registro: id_registro
}, 'json');
bootbox.alert('Registro excluído com sucesso.');
}else {
bootbox.alert('Operação cancelada.');
}
},
buttons: {
cancel: {label: 'Cancelar', className: 'btn-default'},
confirm: {label: 'EXCLUIR', className: 'btn-danger'}
}
});
}
What is going on? the id passed by the delete button, arrives without errors in the confirm function, but in $.post(base_url... is not passing, enough in the controller but without the id
Okay, this will work! But I need to make it work within the framework , so in jquery you have to call the controller (even if you’re doing it) , but you have to take the variable together and you’re not going... , so what you did in this case doesn’t solve by not using a framework but still thanks for the help : )
– Cristian Marques
Yes, that way I use in codeigniter, but I edited for a response to your code, how I would do... post also delete from your controller
– Sr. André Baill
I got it... I’m gonna test it
– Cristian Marques
has some strange button.. it does not arrive in jquery... arrives in modal, shows confirmation and does not go to $('#confirms-delete
– Cristian Marques
If he opened the modal, he called the click function. Where is wrong?
– Sr. André Baill
– Cristian Marques