在流星表格中使用集合助手

时间:2015-06-20 10:00:46

标签: javascript jquery meteor datatables

我正在使用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扩展并添加了帮助器:

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

我的帮助函数可能有什么问题,我应该在哪里声明它?

2 个答案:

答案 0 :(得分:2)

我或多或少完全按照你所做的做了,而且效果很好。

Does Chrome for Android support apps and extensions?
    Chrome apps and extensions are currently not supported on Chrome
    for Android. We have no plans to announce at this time.

我能看到的唯一真正的区别是这一行:

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!";
    }
});

答案 1 :(得分:1)

最后我发现了问题:TabulatTables使用集合变换器dburles:collection-helpers来调用必要的函数,但它与perak:连接定义了自己的助手