Javascript Meteor:如何对简单的todos演示进行分页?
今天我在看流星的分页 我对本回购协议感兴趣: 显示的初始代码看起来很简单:Javascript Meteor:如何对简单的todos演示进行分页?,javascript,meteor,pagination,Javascript,Meteor,Pagination,今天我在看流星的分页 我对本回购协议感兴趣: 显示的初始代码看起来很简单: this.Pages = new Meteor.Pagination("collection-name"); 以及: 以及: {{{#每个任务} {{>任务} {{/每个}} {{text}} 也许今天我的大脑有点迟钝。 我不清楚如何对上述代码进行分页 我如何使用 github.com/alethes/meteor-pages 要从简单的TODO中分页上述代码?我已经有一段时间没有使用meteor页面了,
this.Pages = new Meteor.Pagination("collection-name");
以及:
以及:
{{{#每个任务}
{{>任务}
{{/每个}}
{{text}}
也许今天我的大脑有点迟钝。
我不清楚如何对上述代码进行分页
我如何使用
github.com/alethes/meteor-pages
要从简单的TODO中分页上述代码?我已经有一段时间没有使用meteor页面了,但是您应该能够只替换
Tasks=new Mongo.Collection(“任务”)代码>带有this.Tasks=新Meteor.Pagination(“任务”)代码>-客户端和服务器之间的通用代码
meteor pages基本上只是围绕mongo集合创建一个包装器,并应用搜索和筛选条件
如果您熟悉coffeescript,请确保在repo中查看他们的/examples
目录
此外,这些设置将有助于解释某些默认设置,如每页的项目等。在minimongo中获取任务后,应在获取适当的页面数据之前应用筛选条件和排序条件。如果记录的数量太多,那么通过minimongo的默认meteor机制就不能很好地执行。Mini mongo最适合小型收藏。对于大型集合,请使用具有相同条件的服务器Meteor方法。
<body>
{{> collection-name}}
</body>
<template name="collection-name">
{{> pages}}
{{> pagesNav}} <!--Bottom navigation-->
</template>
Tasks = new Mongo.Collection("tasks");
if (Meteor.isServer) {
// This code only runs on the server
Meteor.publish("tasks", function () {
return Tasks.find({})})}
if (Meteor.isClient) {
// This code only runs on the client
Meteor.subscribe("tasks");
// ...
}
<body>
<ul>
{{#each tasks}}
{{> task}}
{{/each}}
</ul>
</body>
<template name="task">
<li>
{{text}}
</li>
</template>