给你一个原型,在这个基础上再修改吧
$(function () {
//每次加载10个记录,拉到最底部的时候,又加载10个记录
LoadTenItem();
$(window).scroll(function () {
var documentTop = $(document).scrollTop();
var windowHeight = $(window).height();
var documentHeight = $(document).height();
if (documentTop >= (documentHeight - windowHeight)
&& $("#loading").length == 0
) {
$("#loadingTemplate").tmpl().appendTo("#content");
LoadTenItem();
$("#loading").remove();
}
});
});
function LoadTenItem() {
//这里替换为真正的ajax访问
for (i = 0; i < 10; i++) {
$("#itemTemplate").tmpl({ name: "ares", id: i }).appendTo("#content");
}
}
${id}
${name}