使用向下滚动方法注入ajax页面后,Colorbox不起作用

时间:2012-04-01 10:23:05

标签: jquery ajax scroll colorbox

$(document).ready(function() {
    $("a.ajax").colorbox();

    function last_msg_funtion() { 
        var ID = $(".picturebody:last").attr("id");
        $("#last_msg_loader").html('<img src="Pictures/loader.gif">');
        $.ajax({
            type: "POST",
            url: "scrollingajax.php",
            data: "lastmsg="+ ID, 
            cache: false,
            success: function(html){
                $("#content").append(html);
                $("#last_msg_loader").remove();
            }
        });
    };

    $(window).scroll(function(){
        if ($(window).scrollTop() == $(document).height() - $(window).height()){
            last_msg_funtion();
        }
    });
});

使用向下滚动加载更多结果方法后,$().colorbox();只是在将部分网页加载到原始网页后才起作用。这里有新手,很抱歉提出这个问题。使用ajax将更多结果加载到html后,如何获取colorbox函数寄存器?非常感谢!

1 个答案:

答案 0 :(得分:0)

致电$("a.ajax").colorbox();后,您必须再次致电$("#content").append(html);。将新内容插入文档时,新内容不会绑定任何事件侦听器。