我正在使用 Meteor aldeed:tabular 显示表数据
表格初始化代码很简单:
this.TabularTables.Customers = new Tabular.Table({
name: "Clients",
collection: this.Customers,
columns: [
{data: "lastName", title: "Name"},
{data: "myMessage()", title: "Message"}
],
});
第一个字段,lastName 工作正常,但添加第二个字段 myMessage() 会导致问题
我安装了 dburles:collection-helpers 扩展并在公共(public)代码部分添加助手:
this.Customers = new Mongo.Collection("customers");
this.Customers.helpers({
myMessage: function () {
return "Hi!";
}
});
但在客户端仍然出现错误:
Exception from Tracker recompute function:
debug.js:41 TypeError: a[i[j]] is not a function
at c (jquery.dataTables.min.js:16)
at jquery.dataTables.min.js:17
我的辅助函数可能存在什么问题,我应该在哪里声明它?
最佳答案
我所做的或多或少与你所做的完全一样,而且效果很好。
Countries = new Mongo.Collection('countries');
TabularTables = {};
Meteor.isClient && Template.registerHelper('TabularTables', TabularTables);
TabularTables.Countries = new Tabular.Table({
name: "CountriesList",
collection: Countries,
columns: [
{data: 'italian_name', title: 'Italian name'},
{data: 'catalogueName',title: 'Catalogue name'},
{data: "myFunction()", title: 'Wot'}
]
});
Countries.helpers({
myFunction: function () {
return "Hi!";
}
});
我能看到的唯一真正的区别是这一行:
Meteor.isClient && Template.registerHelper('TabularTables', TabularTables);
关于javascript - 在 meteor 表格中使用集合助手,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30952699/