Infinite scroll and the callback

被刻印的时光 ゝ 提交于 2019-11-30 15:40:18

问题


Apologies if this conflicts with a previous post of mine, but I am pretty stuck with the whole callback function of infinite scroll that hopefully someone can help me out.

I'm using the Portfolio Slideshow Pro (http://madebyraygun.com/wordpress/plugins/portfolio-slideshow-pro/) for Wordpress combined with Infinite Scroll.

This is what my infinite scroll JS looks like:

<script>
  $(function(){

    var $container = $('.rest-of-content');

    $container.infinitescroll({
      navSelector  : '.wp-paginate',    // selector for the paged navigation 
      nextSelector : '.wp-paginate li a',  // selector for the NEXT link (to page 2)
      itemSelector : '.single-fg-post',     // selector for all items you'll retrieve
      bufferPX: 20,
      loading: {
          msgText: 'Fetching more gold...',
          finishedMsg: 'We\'ve ran out of gold!',
          img: '<?php bloginfo('template_directory'); ?>/images/ajax-loader-black.gif'
        }

    });

  });
</script>

The slideshow plugin is a whole $(window).load so I took everything inside that, and turned it into a function.

$(window).load(function() { portfolioSlideshow() });

But now I need to callback that function each time the new set of posts load as although the infinitescroll is working, the JS on the slideshow aren't.

Can someone please help me add the function I created to the callback of infinitescroll so it reloads the function each time new data is loaded in?

Thanks so much in advance.

-R


回答1:


$container.infinitescroll({
    navSelector  : '.wp-paginate',    // selector for the paged navigation 
    nextSelector : '.wp-paginate li a',  // selector for the NEXT link (to page 2)
    itemSelector : '.single-fg-post',     // selector for all items you'll retrieve
    bufferPX: 20,
    loading: {
        msgText: 'Fetching more gold...',
        finishedMsg: 'We\'ve ran out of gold!',
        img: '<?php bloginfo('template_directory'); ?>/images/ajax-loader-black.gif'
    }
},
function(arrayOfNewElems)
{
    portfolioSlideshow();
});

This will call portfolioSlideshow() every time the infinitescroll plugin loads new data.



来源:https://stackoverflow.com/questions/8763308/infinite-scroll-and-the-callback

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!