0
$(document).ready(function (e) {
sample(); // Initialize the function
}
function sample() {
$(document).scroll(function (e) {
var scroll_top = $(window).scrollTop();
var document_bottom = scroll_top + $(window).height();
var elementTop = $('.load-more').offset().top;
var elementBottom = (elementTop + $('.load-more').height() - 50) // 50 px offset;
if ((elementBottom <= document_bottom) && (elementTop >= scroll_top)) // User almost reach the end of visible items so load more data. Similar to infinite scroll
{
$(document).unbind("scroll"); // To prevent further requests until the load is complete
$.ajax({
url: "sample", // Sampel URl for AJAX load
type: "GET",
data: {
start: 1
}, // Sample data
dataType: "html",
success: function (data) {
data = $(data);
$('#categories-rendered').append(data).masonry('appended', data); // Masonry append items
$(document).bind("scroll"); // To rebind the scroll event
}
});
}
});
} // Sample function ends here
重新绑定滚动不起作用。这个程序错了吗?jQuery重新绑定事件功能