Simple endless scroll
var page = {
scrollAvailable: true,
currentPage: 0,
init: function() {
var _this = this;
$(window).scroll(function () {
if ($(window).scrollTop() >= $(document).height() - $(window).height() /* - 10 */) {
_this.scroll();
}
});
},
scroll: function() {
var _this = this;
if (this.scrollIAvailable) {
$('#scroll').show();
this.scrollAvailable = false;
this.currentPage += 1;
$.get('page/' + this.currentPage, function(response) {
if (response.status != 'last-page') {
_this.scrollAvailable = true;
}
$('#content').append(response.content);
$('#scroll').hide();
});
}
}
};