基于Discover Meteor的Iron Router中的无限滚动 [英] Infinite Scrolling in Iron Router based on Discover Meteor

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

问题描述

我似乎无法从Commit 12-5进行无限滚动.它只是对mrt add iron-router-progress说,一切都应该正常工作,但是我的页面一直在刷新.这是我正在使用的东西:

I can't seem to get the infinite scrolling to work from Commit 12-5. It says just to mrt add iron-router-progress and everything should work, but my page keeps refreshing. Here's what I'm working with:

PostsListController = RouteController.extend({
    template: 'blog',
    increment: 20,
    limit: function() {
        return parseInt(this.params.postsLimit) || this.increment;
    },
    waitOn: function() {
        return Meteor.subscribe('posts', this.limit());
    },
    posts: function() {
        return Posts.find({}, {
            limit: this.limit()
        });
    },
    data: function() {
        var hasMore = this.posts().count() === this.limit();
        var nextPath = this.route.path({
            postsLimit: this.limit() + this.increment
        });
        return {
            posts: this.posts(),
            nextPath: hasMore ? nextPath : null
        };
    }
});

Router.map(function() {
    this.route('blog', {
        path: '/:postsLimit?',
        controller: PostsListController
    })
})

Router.configure({
    layoutTemplate: 'layout',
    notFoundTemplate: 'notFound',
});

当我单击加载更多"时,一切似乎都可以正常工作,该页面闪烁并跳回到顶部!

Everything seems to work EXCEPT when I click load more, the page blinks and jumps back up to the top!

推荐答案

正如您可以在GitHub中阅读有关提交的问题一样,它实际上是Iron-router的0.7.1版本中的一个错误.使用他们使用的版本(查找smart.lock文件),它不会刷新并转到顶部.

As you can read in the GitHub issues related the commit, it is actually a bug in the 0.7.1 version of iron-router. With the version they used (look up the smart.lock file) it won't refresh and go to the top.

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

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