I need to validate if button
with class .pop-yes
has been clicked, but I need to validate this out of the .click()
event so that the $(this).parent [...]
line is executed.
The way it's here, it runs before I click on .pop-yes
, and if I put it inside the .click()
function, it just does not run.
$(function() {
// .delete recebe o id que devo deletar..
$(".delete").click(function(){
var element = $(this);
var id = element.attr("id");
var info = 'id=' + id;
$('.pop').fadeIn("slow");
$('.pop-no').click(function(){
$('.pop').fadeOut("slow");
});
//Aqui eu clico para confirmar o delete
$('.pop-yes').click(function(){
$('.pop').fadeOut("slow");
$.ajax({
type: "POST",
url: "/removeClient",
data: info,
success: function () {
return true;
}
});
});
// aqui faz a row da table sumir sem carregar a página
// porem eu só quero que ela seja executada caso o .pop-yes.click() seja true
// Se eu coloco ela dentro da .pop-yes.click() ela não funciona acho que não encontra a #show
$(this).parents("#show").animate({backgroundColor: "#003"}, "slow").animate({opacity: "hide"}, "slow");
});
});
Part of code html
:
<tr id="show" class="tr_<?= $client['id'];?>">
<td><?= $client['name']; ?></td>
<td><?= $client['email']; ?></td>
<td><?= $client['nickname']; ?></td>
<td><?= $client['hour_value']; ?></td>
<td><?= $client['discount']; ?></td>
<td><?= $client['date_pagment']; ?></td>
<td><?= $client['cep']; ?></td>
<td class="text-center">
<button id="<?= $client['id']; ?>" class="delete glyphicon glyphicon-remove"></button>
</td>
</tr>
<!-- Modal -->
<div class="pop">
<div class="pop-up">
<h4>Message <?= $client['name']; ?> </h4>
<button class="btn btn-danger pop-no" >Não</button>
<button class="btn btn-primary pop-yes">Sim</button>
</div>
</div>