无限滚动手动触发 [英] infinite scroll manual trigger

查看:77
本文介绍了无限滚动手动触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

似乎似乎行不通... :-(已经看到更多关于它的投诉,但我找不到答案.

Just doesn't seem to work... :-( Have seen more complaints about it but I can't find the answer.

问题: 无限滚动有效,但手动触发无效. 当我单击链接时,没有任何反应. Firebug提供

The Problem: Infinite scroll works but not the manual trigger. When I click the link, nothing happens. Firebug gives

无限滚动

我的代码:

    <?php echo ('<ul id="infinite">'); ?>
<?php 
$wp_query = new WP_Query();
$wp_query->query('paged='.$paged.'&cat=5&showposts=3&meta_key=video_video&orderby=meta_value&order=ASC'  . $post->ID);
while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
<?php if ( get_post_meta($post->ID, 'video_video', true) ) : ?>
    <li class="video"><?php $home = array("h" => 290, "w" => 380, "zc" => 1, "q" =>100);
            //echo get('video_video');
            echo ('With: ');
            echo get('participant_first_name');
            echo ('&nbsp;');
            echo get('participant_last_name');
            echo ('</li>');?>

<?php endif;?>


<?php endwhile;?>

<?php if (get_post_meta($post->ID, 'video_video', true) ) { ?>
    <?php if ($wp_query->max_num_pages > 1) : ?>
        <nav id="nav-below" >
        <div id="next" >
        <?php next_posts_link( __( 'Scroll down for more', 'intowntheme' ) ); ?></div>
        </nav>
    <?php endif; //end nav ?>
<?php } else {  ?>
<p>There are no interviews at the moment </p>
<?php }   ?>     
</ul>     

还有我的脚本:

jQuery('ul#infinite').infinitescroll({ 
    navSelector  : "#next",  // selector for the paged navigation (it will be hidden)
    nextSelector : "#next a",   // selector for the NEXT link (to page 2)
    itemSelector : "ul#infinite li",  // selector for all items you'll retrieve
    errorCallback: function() { 
          // fade out the error message after 2 seconds
          $('#infscr-loading').animate({opacity: 0.8},2000).fadeOut('normal');   
        },   
    loading         : {
         msgText: "<em>Loading the next year of Grantees...</em>",
        finishedMsg: "<em>You've reached the end of the Interviews.</em>"
    },
  });

  //kill scroll binding
    jQuery(window).unbind('.infscr');
    //setTimeout("jQuery('#next').slideDown();", 1000);
     //hook up the manual click guy.

    jQuery('#next a').click(function(){
        jQuery('#next a').infinitescroll('retrieve.infscr');
     return false;
    });

也尝试过

jQuery(document).trigger('retrieve.infscr');

代替

jQuery('#next a').infinitescroll('retrieve.infscr');

但没有运气.

Firebug然后说 trigger(retrieve.infscr) called incorrectly

Firebug then says trigger(retrieve.infscr) called incorrectly

推荐答案

Pfoe,找到了它……长期有效的文档(此插件不提供!)

Pfoe, found it... Long live good documentation (NOT with this plugin!)

:

 jQuery('#next a').click(function(){
    jQuery('#next a').infinitescroll('retrieve.infscr');
 return false;
});

应为:

jQuery('#next a').click(function(){
    jQuery('ul#infinite').infinitescroll('retrieve');
 return false;
});

最大的问题是.infscr,它不应该存在. 希望它对其他人有帮助.

the biggest problem was the .infscr which shouldn't be there.. Hope it helps someone else..

类似文档的解决方案:

jQuery("#clickable_element").click(function(){
    jQuery('#main_content_container').infinitescroll('retrieve');
        return false;
});

注意:
您可能必须添加手动触发行为如果您正在使用砖石或同位素以使其工作.只需在无限滚动之后添加manual-trigger.js,然后在调用插件时通过传递behavior: 'twitter'来传递行为.

Note:
You may have to add the manual trigger behavior if you are working with masonry or isotope in order to make it work. Just include manual-trigger.js after infinitescroll and pass the behavior by passing behavior: 'twitter' when calling the plugin.

这篇关于无限滚动手动触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆