使用表格在流星中创建客户端列表 table
Creating a client list table in meteor using tabular
我正在处理 Base User 管理项目,来自:
https://github.com/themeteorchef/building-a-user-admin
我想使用 aldeed:tabular 将用户列表 table 更改为数据表。我在用户模板中有以下内容:
{{> tabular table=TabularTables.UsersAdmin selector=selector class="table table-striped table-bordered table-condensed"}}
并在 client/lib/userAdmin.js 中添加了
Meteor.isClient && Template.registerHelper('TabularTables', TabularTables);
Template.users.rendered = function(){
TabularTables.UsersAdmin = new Tabular.Table({
name: "User List",
collection: Meteor.users,
pub:"users",
columns: [{data:"roles",title:"Role",
render: function (val, type, doc) {
return val[0];
}},
{
data: "emails",
title: "Email",
render: function (val, type, doc) {
return val[0].address;
}
}],
});
}
如果我呈现用户页面,我得到:
Uncaught ReferenceError: TabularTables is not defined.
Error: You must pass Tabular.Table instance as the table attribute
at null.<anonymous> (tabular.js:119)
我认为这是一些发布问题,但是,如果我在控制台中输入:
Meteor.users.findOne().emails[0].address
Meteor.users.findOne().roles[0]
两个参数 returns 函数,因此管理员用户可以使用这些变量。
有任何想法吗?我是不是表格用错了?
发现错误:
参考和一切都是正确的。只是忘了包括:
TabularTables = {};
在顶部。此外,TabularTables 代码应位于客户端和服务器 space 中。
:-o 是的。浪费了太多时间!
我正在处理 Base User 管理项目,来自: https://github.com/themeteorchef/building-a-user-admin
我想使用 aldeed:tabular 将用户列表 table 更改为数据表。我在用户模板中有以下内容:
{{> tabular table=TabularTables.UsersAdmin selector=selector class="table table-striped table-bordered table-condensed"}}
并在 client/lib/userAdmin.js 中添加了
Meteor.isClient && Template.registerHelper('TabularTables', TabularTables);
Template.users.rendered = function(){
TabularTables.UsersAdmin = new Tabular.Table({
name: "User List",
collection: Meteor.users,
pub:"users",
columns: [{data:"roles",title:"Role",
render: function (val, type, doc) {
return val[0];
}},
{
data: "emails",
title: "Email",
render: function (val, type, doc) {
return val[0].address;
}
}],
});
}
如果我呈现用户页面,我得到:
Uncaught ReferenceError: TabularTables is not defined.
Error: You must pass Tabular.Table instance as the table attribute
at null.<anonymous> (tabular.js:119)
我认为这是一些发布问题,但是,如果我在控制台中输入:
Meteor.users.findOne().emails[0].address
Meteor.users.findOne().roles[0]
两个参数 returns 函数,因此管理员用户可以使用这些变量。 有任何想法吗?我是不是表格用错了?
发现错误: 参考和一切都是正确的。只是忘了包括:
TabularTables = {};
在顶部。此外,TabularTables 代码应位于客户端和服务器 space 中。
:-o 是的。浪费了太多时间!