David Garcia
David Garcia

Reputation: 2696

Trigger infinitescroll manually

I am using the following code to trigger infinitescroll on isotope masonry, however how do I use the "Click to load more posts" instead, "the manual trigger". I tried implementing from solutions on the internet but they do not work for me. Thanks.

/*--------------------------------------------------------------------------------*/
/*  infinitescroll
/*--------------------------------------------------------------------------------*/
jQuery(document).ready(function($) {
    var $container = $('.masonry');
    $container.imagesLoaded( function(){
    $container.isotope({
        itemSelector : '.item'
    });   
});
$container.infinitescroll({
        // selector for the paged navigation
        navSelector  : '.post-nav',     
        // selector for the NEXT link (to page 2)
        nextSelector : '.post-nav .prev-post a',  
        // selector for all items you'll retrieve
        itemSelector : '.item',     
        loading: {
            finishedMsg: 'No more pages to load.',
            img: 'http://i.imgur.com/qkKy8.gif'
        }
    },
    function( newElements ) {
        var $newElems = $( newElements ).css({ opacity: 0 });
        $newElems.imagesLoaded(function() {
            $newElems.animate({ opacity: 1 });
            $container.isotope( 'appended', $( newElements ) ); 
            $container.isotope('reLayout');
        });
    });
});

Upvotes: 0

Views: 2141

Answers (1)

BenM
BenM

Reputation: 53198

Assuming that you're using this plugin, the following should work to manually trigger a retrieve:

$container.infinitescroll('retrieve');

Upvotes: 5

Related Questions