我有下表可以正常使用。 Beeing一个管理员帐户我发布了整个Meteor.users集合。我在root / 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更改为任何客户端或品牌集合,或者甚至在此代码上方插入console.log(客户端),我会得到:“客户端未定义”错误。 如果我输入控制台>客户端在运行重新运行应用程序之前,它可以正常使用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
我在应用程序的其他位置使用此集合,它工作正常。自从我安装了表格包 事情以某种方式失控。我没有从这个开始的想法。 我现在正在努力工作两天才能让它发挥作用,但网上关于这个包(以及大多数流星相关主题)的信息很少,我决定发布这个问题。
答案 0 :(得分:1)
我不确定,看起来像加载订单问题
尝试在同一文件(例如
)中初始化集合后编写表格代码 在root / lib文件夹中Clients = new Meteor.Collection("client");
Brands = new Meteor.Collection("brand");
Meteor.isClient && Template.registerHelper('TabularTables', TabularTables);
TabularTables.Users = new Tabular.Table({
name: "UserList",
collection: Meteor.users, //Clientsor Brands
pub:"pubUsers"
columns: [
{data: "username", title: "User name"},
{
data: "emails",
title: "Email",
render: function (val, type, doc) {
return val[0].main
}
},