[英]Using collection helpers in meteor tabular
I'm displaying table data using Meteor aldeed:tabular 我正在使用流星aldeed:tabular显示表数据
The tabular initialization code is simple: 表格初始化代码很简单:
this.TabularTables.Customers = new Tabular.Table({
name: "Clients",
collection: this.Customers,
columns: [
{data: "lastName", title: "Name"},
{data: "myMessage()", title: "Message"}
],
});
First field, lastName works perfectly, but adding second field myMessage() causes the problem 第一个字段,lastName正常运行,但是添加第二个字段myMessage()会导致问题
I installed dburles:collection-helpers extension and add helper in common code section: 我安装了dburles:collection-helpers扩展,并在通用代码部分添加了助手:
this.Customers = new Mongo.Collection("customers");
this.Customers.helpers({
myMessage: function () {
return "Hi!";
}
});
But still getting error on the client side: 但是在客户端仍然出现错误:
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
What might be the problem with my helper function and where should I declare it? 我的助手功能可能有什么问题,应该在哪里声明?
I've done more or less exactly what you have done and it works nicely. 我已经或多或少地准确地完成了您所做的工作,并且效果很好。
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!";
}
});
The only real difference I can see is this line: 我可以看到的唯一真正的区别是这一行:
Meteor.isClient && Template.registerHelper('TabularTables', TabularTables);
最终我发现了问题:TabulatTables使用集合转换器dburles:collection-helpers来调用必要的函数,但是它与perak:joins冲突,后者定义了自己的助手
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.