2015-06-20 55 views
1

伙计。我在我的Meteor应用中使用alethes:pages进行分页,我需要使用现有订阅来控制它显示的数据。看起来它的工作方式是它只是对一个集合中的所有记录进行分页,而不是我想要显示的特定内容。使用alethes进行分页:使用订阅的页面

我已经走到这一步,是这样的,定义分页代码:

BrowsePages = new Meteor.Pagination(Mods, { 
    perPage: 15, 
    sort: { 
     createdAt: -1 
    }, 
    templateName: "browseModsList", 
    itemTemplate: "browseModItem", 
    table: { 
     fields: ["name", "category", "createdAt"], 
     header: ["Name", "Author", "Category", "Date Added", "Rating", "Current Version"], 
     class: "table table-striped" 
    }, 
    divWrapper: false, 
    auth: function(skip, sub) { 
     var theCat = Categories.findOne({slug: Router.current().params.slug}); 
     return Mods.find({category: theCat._id}); 
    } 
}); 

我是假设,这将限制分页数据给我通过auth返回游标,但它的现在只是在那里悬挂着一个微调器。

我很困惑,任何人可以摆脱这一点,这将是很棒的。我正在寻求对分页执行相同的限制(不知何故),我只是不知道该怎么做。

这里有更多的相关代码:

路线:

// Browse 
Router.route('/browse/:slug', function() { 
    this.render('browseModsList'); 
}, { 
    name: 'browse', 
    waitOn: function() { 
     return [ 
      Subs.subscribe('catMods', this.params.slug) 
     ] 
    } 
}); 

出版

提前
Meteor.publish('catMods', function(tag) { 
    var category = Categories.findOne({slug: tag}); 
    if (category) { 
     var catId = category._id; 
     return Mods.find({category: catId}); 
    } else { 
     return this.ready(); 
    } 
}); 

由于时间的任何援助,像往常一样!

回答

0

添加字段键,如下所示。

BrowsePages = new Meteor.Pagination(Mods, { 

    perPage: 15, 
    fields: {name: 1, category:1, createdAt:1}, 

});