0

livequeryなぜイベントをバインドしないのかわかりませんが、を使用する必要があります.click。これは単なる例であり、も使用する可能性があります.click()が、実際のコードでは、を使用する必要がありますlivequery。なぜ機能しないのか誰かが知っlivequery ていますか?

function bind_remove(comment){
    var id = comment.attr('comment_id');    
    comment.find(".remove").livequery("click", function(e){    
        $.post("/deleteComment", {id: id}, function(response){
            comment.remove();
            comments = comments_container.find('.comment');
        });    
    });
}

$(document).ready(function(){    

    var comments_container = $('#comments_container');
    var comments = comments_container.find('.comment');

    comments.each(function(){
        bind_remove($(this));
    });
    
    $(".submit_button").livequery("click", function(e){
    $.post("/newComment", {text: textarea.val()}, function(response){                    
        comments_container.last().append($(response).fadeIn('slow',function(){                    
                comments = comments_container.find('.comment');
                bind_remove(comments.last());                            
            }));
        });
    });
});
4

2 に答える 2

0

交換してみてください

comment.find(".remove").livequery("click", function(e){

これとともに

comment.find(".remove").live("click", function(e){
于 2011-03-27T17:10:53.940 に答える
0

最後のコメントにランダムなIDを追加し、'last()'を使用せずに$('#myid')で選択しました。それから私はそれをバインドして働き始めました

于 2011-05-04T11:57:41.270 に答える