I'm trying to delete a record from the Bootstrap modal window, but it's not working.
Look how I did it:
When you click the delete button for a particular record
<a class="btn btn-primary delete" href="#" data-href="#" data-target="#confirm-delete" data-toggle="modal" id="<?php echo $codigoform;?>">Apagar experiência</a>
jQuery interprets the command:
$('a.delete').click(function() {
var id = $(this).attr('id');
var data = 'id=' + id ;
var parent = $(this).parent().parent().parent().parent();
var $meu_alerta = $("#confirm-delete");
$meu_alerta.modal().find(".btn-ok").on("click", function() {
$.ajax({
type: "POST",
url: "deletar_formacao.php",
data: data,
cache: false,
success: function() {
parent.fadeOut('slow', function() {$(this).remove();});
window.location.reload();
}
});
});
});
The page "deletar_formacao.php" reads the code through the post method and excludes the registry.
I have detected that it is as if the modal window and the onclick event of the delete class were competing. Could you give me some help?