Disappear two Ivs with jquery

Asked

Viewed 93 times

0

First of all I made a foreach in my bank but the code will be very extensive continuing, What I want to do is for the user to click on the link to appear a directory of a div, in this div will have a link to actually delete the article the problem is when I delete the article, The article div doesn’t just disappear the window-frame div, and I’d like that covenant window appear only on the clicked div. I thank all who help me and constructive criticism will be welcome

<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript">
$("document").ready(function(){

$('.excluir').click(function(){
    $('.janela-moldal').fadeIn();
});

$('.chamar-moldal').click(function(){
    $('.janela-moldal').fadeIn();
});

$('.cancelar').click(function(){
    $('.janela-moldal').fadeOut();
});

$(".excluir-artigo").live('click',function(){
         $.post('php/deletar.php', {coment:$(this).attr('id')});
         $(this).parent('div').fadeOut();
      $(".janela-moldal").fadeOut();
    };
});

});


</script>

<?php
    $artigo[] = array();
    $artigo['artigo_id'] = 1;
    $artigo['frase'] = '"A vingança nunca é plena, mata a alma e a invenena"';
?>


<div class="artigos" id="artigos"> 
    <?=$artigo['artigo_id']; ?>
    <h1><?= $artigo['frase']; ?></h1>
    <a class="chamar-moldal" href="javascript:void(0);">chamar a div de confirmacão </a>
</div>

<div class="janela-moldal" style="display:none"> 
    <h1>Deseja excluir este artigo?</h1>
    <a class="cancelar" href="javascript:void(0);">cancelar</a>
    <a class="excluir-artigo" id="artigo-<?=$artigo['artigo_id']?>" href="javascript:void(0);">excluir</a>
</div>

1 answer

1

Place Modal inside the article div

<div class="artigos" id="artigos"> 
    <?=$artigo['artigo_id']; ?>
    <h1><?= $artigo['frase']; ?></h1>
    <a class="chamar-moldal" href="javascript:void(0);">chamar a div de confirmacão </a>

    <div class="janela-moldal" style="display:none"> 
        <h1>Deseja excluir este artigo?</h1>
        <a class="cancelar" href="javascript:void(0);">cancelar</a>
        <a class="excluir-artigo" id="artigo-<?=$artigo['artigo_id']?>" href="javascript:void(0);">excluir</a>
    </div>
</div>

And when removing, call Parent() twice.

$(".excluir-artigo").live('click',function(){
     $.post('php/deletar.php', {coment:$(this).attr('id')});
     $(this).parent('div').parent('div').fadeOut();  // VOcê pode fazer assim
     //$(this).parent().parent().fadeOut();   // Ou assim
     $(".janela-moldal").fadeOut();
    };
});

Browser other questions tagged

You are not signed in. Login or sign up in order to post.