Auto click when user scrolls to the end of the page
<p>I'm trying to create an infinite scroll feature on my site but it isn't working. 
My code:</p>

<pre><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('&lt;img src="' + base_url + 'images/core/loader2.gif"/&gt;');
    post.load_more_messages($(this).attr('data-last_id'));
});
</code></pre>

<p>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.</p>
