【发布时间】:2015-03-08 16:13:17
【问题描述】:
我有下表可以正常工作。作为一个管理员帐户,我发布了整个 Meteor.users 集合。我在根 /lib 的一个文件中也有两个数据库
Clients = new Meteor.Collection("client");
Brands = new Meteor.Collection("brand");
它们现在像这样在 /server/lib 文件夹中发布
Meteor.publish("pubClients", function(){
return Clients.find();
});
Meteor.publish("pubBrands", function(){
return Brands.find();
});
Meteor.publish("pubUsers", function(){
return Meteor.users.find();
});
并在 client/lib 文件夹中这样订阅
Meteor.subscribe('pubClients');
Meteor.subscribe('pubBrands');
Meteor.subscribe('pubUsers');
我正在使用以下模板来注入 html: {{> tabular table=TabularTables.Users selector=selector class="table table-striped table-bordered table-condensed"}}
现在,如果我尝试将 Meteor.user 更改为任何 Clients 或 Brands 集合,甚至在此代码上方插入 console.log(Clients),我会收到:“Clients is not defined”错误。 如果我在运行重新运行应用程序之前输入控制台 > 客户端,它可以与 Mongo.Collection 等一起正常工作。 如果我运行它,我也会在控制台中收到未定义的消息。 这是我的代码(实际上是 aldeed 的代码 :)):
TabularTables = {};
Meteor.isClient && Template.registerHelper('TabularTables', TabularTables);
TabularTables.Users = new Tabular.Table({
name: "UserList",
collection: Meteor.users,
pub:"pubUsers"
columns: [
{data: "username", title: "User name"},
{
data: "emails",
title: "Email",
render: function (val, type, doc) {
return val[0].main
}
},
{
data: "emails",
title: "verified",
render: function (val, type, doc) {
return val[0].verified?"☑":"☐";
}
},
{
data: "profile",
title: "Account",
render: function (val, type, doc) {
return val.accType;
}
},
{
data: "profile",
title: "Active",
render: function (val, type, doc) {
return val.active?"active":"pending";
}
},
{
data: "createdAt",
title: "Singned up",
render: function (val, type, doc) {
return moment(val).calendar();
}
},
{
tmpl: Meteor.isClient && Template.bookCheckOutCell
}
]
});
有什么想法吗?
非常感谢。这是我的包裹清单:
accounts-base 1.1.3 A user account system accounts-password 1.0.5 Password support for accounts aldeed:tabular 0.2.3 Datatables for large or small datasets in Meteor insecure 1.0.2 Allow all database writes by default iron:router 1.0.6 Routing specifically designed for Meteor meteor-platform 1.2.1 Include a standard set of Meteor packages in your app momentjs:moment 2.9.0 Moment.js (official): parse, validate, manipulate, and display dates - official Meteor packaging sergeyt:typeahead 0.10.5_7 Autocomplete package for meteor powered by twitter typeahead.js twbs:bootstrap 3.3.1_2 Bootstrap (official): the most popular HTML/CSS/JS framework for responsive, mobile first projects
我在应用程序的其他地方使用这个集合,它工作正常。由于我安装了表格包 事情不知何故失控了。我不知道要从哪里开始。 我现在苦苦挣扎了两天才能让它工作,但是网上关于这个包(以及大多数 Meteor 相关主题)的信息太少了,所以我决定发布这个问题。
【问题讨论】: