jquery - 无限滚动 完成后删除分页器

标签 jquery infinite-scroll

当我们完成演示时,我需要删除分页器 http://www.infinite-scroll.com/trigger.html

    // remove the paginator when we're done.
    $(document).ajaxError(function(e,xhr,opt){
      if (xhr.status == 404) $('a#next').remove();
    });

但是这段代码不起作用。我在演示中提到过 Infinite Scroll 的版本是 1.5.100504,但我在这里下载的最新版本是 2.0b2.110713 那么,有什么帮助吗?

也许这可以帮助我:

state: {
    isDuringAjax: false,
    isInvalidPage: false,
    isDestroyed: false,
    isDone: false, // For when it goes all the way through the archive.
    isPaused: false,
    currPage: 1
  },

最佳答案

您的网站永远不会发回 404 http 状态代码,因此此行永远不会起作用:

if (xhr.status == 404) jQuery('#load-more').find('.text').html('No more posts to load.').end().delay(2000).fadeOut();

“没有更多帖子要加载”消息来自无限滚动初始化的“finishedMsg”属性。

如果你要添加

finished: function() {
    if (this.options.state.isDone) {
        $('#load-more').remove();
    }
},

配置的加载属性:

$container.infinitescroll({
            navSelector: '#nav-pagination-load-more',
            nextSelector: '#nav-pagination-load-more .next',
            itemSelector: '.hentry',
            loading: {
                selector: '#load-more',
                finishedMsg: 'No more posts to load.',
                img: 'http://cdn.moozpaper.com/lucidpress/wp-content/themes/lucidpress/images/loading_small.gif',
                // like so: ==============================
                finished: function() {
                    if (this.options.state.isDone) {
                        $('#load-more').remove();
                    }
                }, 
                msgText: ''
            },
            behavior: 'local'
        },

它应该可以满足您的需要。但这很难说,因为这个版本的插件没有很好的文档记录。

关于jquery - 无限滚动 完成后删除分页器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11566862/

相关文章:

javascript - 有没有办法从 Highcharts 传入可变元素 ID 以启动模式窗口?

javascript - Ember.ListView 不适用于最新的 ember-cli (0.1.7)

javascript - 使用knockout js滚动显示分页

javascript - 快速滚动时函数会多次触发

jquery - 获取鼠标滚轮 JQuery 事件处理程序的方向

javascript - CSS如何删除右边、左边和底部的空格

JAvascript 180 到 -180 旋转

jquery - 具有自定义外观的跨浏览器内容滚动

ios - 无限滚动和重复数据

php - Yii2 中的滚动寻呼机扩展