0

After ajax added new containers it killed methods initialized for them, what can I do to make django-endless-pagination add some JQuery to its generated containers? For example i have:

$(".fact").each(function() {
   $(this).css('border-top', '5px solid ' + colors[Math.floor(Math.random() * colors.length)]);
});

and i want to add this to each .fact generated after ajax call.

4

1 回答 1

0

查看文档中的附加回调部分:)

假设这是您无尽的分页初始化,您可以添加一些代码以在每次新的重新加载时执行。

<script>
    $.endlessPaginate({
        paginateOnScroll: true,
        paginateOnScrollMargin: 100,
        paginateOnScrollChunkSize: 5,
        // add your code in onCompleted 
        onCompleted: function(context, fragment) {
            $(".fact").each(function() {
                $(this).css('border-top', '5px solid ' + colors[Math.floor(Math.random() * colors.length)]);
                });
            });

        }
    });
</script>
于 2015-04-13T14:50:22.967 回答