jQuery load content when scroll to bottom-100px of page, multiple events fired
I was having this same problem too. I came across this link and it really helped (and worked)!
Update: I looked at the code and I think that when you rebind, you are missing the function to rebind to.
jsFiddle
function loadMore()
{
console.log("More loaded");
$("body").append("<div>");
$(window).bind('scroll', bindScroll);
}
function bindScroll(){
if($(window).scrollTop() + $(window).height() > $(document).height() - 100) {
$(window).unbind('scroll');
loadMore();
}
}
$(window).scroll(bindScroll);
This will help you.
<script type="text/javascript">
var sIndex = 11, offSet = 10, isPreviousEventComplete = true, isDataAvailable = true;
$(window).scroll(function () {
if ($(document).height() - 50 <= $(window).scrollTop() + $(window).height()) {
if (isPreviousEventComplete && isDataAvailable) {
isPreviousEventComplete = false;
$(".LoaderImage").css("display", "block");
$.ajax({
type: "GET",
url: 'getMorePosts.ashx?startIndex=' + sIndex + '&offset=' + offSet + '',
success: function (result) {
$(".divContent").append(result);
sIndex = sIndex + offSet;
isPreviousEventComplete = true;
if (result == '') //When data is not available
isDataAvailable = false;
$(".LoaderImage").css("display", "none");
},
error: function (error) {
alert(error);
}
});
}
}
});
</script>
Go through this link for whole article and details how to fire multiple event.
load more content when browser scroll to end of page in jquery