我正在使用alethes:分页,但我不明白如何使它工作。我的收藏中有4个帖子,我希望每页显示2个帖子。这是代码。
app.js
BlogPosts = new Mongo.Collection("blogPosts");
if (Meteor.isClient) {
Template.body.helpers({
blogPosts: function() {
return BlogPosts.find({});
}
});
}
Pages = new Meteor.Pagination(BlogPosts, {
itemTemplate: "post",
perPage: 2
});
app.html
<head>
<title>pagination</title>
</head>
<body>
{{> pages}}
{{> pagesNav}}
</body>
<template name="post">
{{title}}
</template>
答案 0 :(得分:1)
您必须为alethes支持的集合提供2个模板名称。
一个用于页面本身,另一个用于分页内容的项目。
在你的JS中
PaginatedStuff = new Meteor.Pagination(Polls, {
perPage:6,
templateName: 'paginatedStuff',
itemTemplate: 'stuffListItem'
});
您希望获得分页内容的位置:
{{>paginatedStuff}}
最后是两个模板
<template name="paginatedStuff">
{{> pages}}
{{> pagesNav}}<!-- bottom navigation -->
</template>
<template name="stuffListItem">
<!-- stuff to display your item here -->
</template>