Welcome Guest, Not a member yet? Register   Sign In
[solved] jquery removing parent
#3

[eluser]cideveloper[/eluser]
What's with all the javascript questions in the codeigniter forums?

$(this) inside a .post returns the jquery post object not the object clicked. Do a console log on $(this) and you will see

Code:
$('a.trinti_img').live('click',function(e){
    e.preventDefault();
    $.post("test.php", {filename: name}, function(data){
        console.log(data.response);
        //$(this).parent().remove();
        console.log($(this));
    });

});

you need to get the element before you post.

Code:
$('a.trinti_img').live('click',function(){
        
        name = this.id;
        var elem_clicked = $(this);
        
         jConfirm('Ar tikrai norite ištrinti?', 'Patvirtinimas', function(r) {
             if(r){
                
                
                 $.post(CI.base_url + 'admin_/naujienos/delete_picture_ajax/'+name,{filename: name},  function(data) {
                    
                     if(data != 'not_admin') //this is true
                         elem_clicked.parent().remove();
                         //console.log('test');
                    
                    });
             } //if r
         });
         return false;
     });


Messages In This Thread
[solved] jquery removing parent - by El Forum - 12-29-2010, 11:42 AM
[solved] jquery removing parent - by El Forum - 12-29-2010, 12:24 PM
[solved] jquery removing parent - by El Forum - 12-29-2010, 03:24 PM
[solved] jquery removing parent - by El Forum - 12-30-2010, 12:58 AM



Theme © iAndrew 2016 - Forum software by © MyBB