手动触发infinitescroll

时间:2013-02-13 18:21:05

标签: javascript wordpress infinite-scroll

我使用以下代码触发infinitescroll on isotope砌体,但​​是如何使用“Click to load more posts”代替“手动触发器”。我尝试从互联网上的解决方案实施,但它们不适合我。感谢。

/*--------------------------------------------------------------------------------*/
/*  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');
        });
    });
});

1 个答案:

答案 0 :(得分:5)

假设您正在使用this plugin,以下操作应该可以手动触发检索:

$container.infinitescroll('retrieve');