Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 140734

Auto click when user scrolls to the end of the page

$
0
0

I'm trying to create an infinite scroll feature on my site but it isn't working. My code:

var post = {}
post.load_moreBtn = $('#home_load_more');
if($(window).scrollTop() + $(window).height() == $(document).height()) {
    post.load_moreBtn.trigger('click');
}
post.load_moreBtn.on('click', function () {
    $(this).html('<img src="' + base_url + 'images/core/loader2.gif"/>');
    post.load_more_messages($(this).attr('data-last_id'));
});

If I put an alert in place of the trigger it works,also if I remove the scroll detection bit, the load more works fine. Just can't get it to autoload, please help.


Viewing all articles
Browse latest Browse all 140734

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>