Level 75
Have you tested your pagination without ajax to ensure you query is correct?
When I dd($allStatuses), it gave 9 items. My pagination is 3 items per page. When I scrolled my homepage to the bottom, it repeated the last 3 items once.
I tried ?page=4, and it resulted none. When I tried ?page=3 and scrolled down, it repeated the same items in ?page=3 once.
<script>
$(document).ready(function() {
$(window).scroll(fetchPosts);
function fetchPosts() {
var page = $('.endless-pagination').data('next-page');
if(page !== null) {
clearTimeout($.data(this, "scrollCheck"));
$.data(this, "scrollCheck", setTimeout(function() {
var scroll_position_for_posts_load = $(window).height() + $(window).scrollTop() + 100;
if(scroll_position_for_posts_load >= $(document).height()) {
$.get(page, function(data) {
$('.allStatuses').append(data.allStatuses);
$('.endless-pagination').data('next-page', data.next_page);
});
}
}, 350));
}
}
});
</script>
Please or to participate in this conversation.