Meteor 流星分页
我正在尝试使用。在我的JavaScript代码中,我有:Meteor 流星分页,meteor,Meteor,我正在尝试使用。在我的JavaScript代码中,我有: Tasks = new Mongo.Collection("tasks"); Tasks.attachSchema(new SimpleSchema({ title: { type: String, label: "Title", max: 200 }, complete: { type: Boolean, defaultValue: false, label: " ",
Tasks = new Mongo.Collection("tasks");
Tasks.attachSchema(new SimpleSchema({
title: {
type: String,
label: "Title",
max: 200
},
complete: {
type: Boolean,
defaultValue: false,
label: " ",
autoform: {
type: "boolean-checkbox"
}
},
dueDate: {
type: Date,
label: "Due Date",
optional: true,
autoform: {
type: "pickadate"
}
}
}));
Pages = new Meteor.Pagination(Tasks, {
templateName: "tasksPaginated"
})
在我的html中,我有:
<template name="TaskList">
Before
{{> tasksPaginated}}
After
</template>
<template name="tasksPaginated">
{{> pages}}
{{> pagesNav}} Bottom navigation
</template>
之前
{{>tasksPaginated}
之后
{{>页面}
{{>pagesNav}}底部导航
当我尝试浏览到该页面时,出现以下错误:
传递调用“pages\u tasks/CountPages”的结果时出现异常:
错误
连接时。\u livedata\u结果()
在onMessage()上
在
at Array.forEach(本机)
at Function..each..forEach()
在SockJS.self.socket.onmessage()上
在SockJS.REventTarget.dispatchEvent()上
在SockJS.\u dispatchMessage()
在SockJS._didMessage()
在WebSocket.that.ws.onmessage()上
你知道我做错了什么吗?meteor页面的文档说你可以这样初始化它:
this.Pages = new Meteor.Pagination("tasks");
这将自动获取一个名为“任务”的模板。另一种方法(我认为您需要)是指定不同的模板,在这种情况下,您的代码应该是:
this.Pages = new Meteor.Pagination("tasks", {itemTemplate: "tasksPaginated"});
这将为您解决问题请确保代码正确
Pages = new Meteor.Pagination(Tasks, {
templateName: "tasksPaginated"
})
当我这样做时,不要在Template.tasksPaginated全局可用之前运行:this.Pages=new Meteor.Pagination(“任务”);,我收到错误:“任务”集合是在外部创建的。将集合对象而不是集合的名称传递给构造函数。[集合不可访问]”