javascript - 在 meteor 表格中使用集合助手

标签 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 扩展并在公共(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/

相关文章:

javascript - 如何从 javascript 触发按钮 onmouseup 处理程序

javascript - 在 javascript 中使用 .h 定义

javascript - Lightbox2 下一个箭头在组的第一个图像之后消失

javascript - jQuery scrollTop 检测需要很长时间

javascript - onbeforeunload 在所有浏览器中的无缝行为

meteor - 将文件添加到 meteor 构建中的 bundle 中

Meteor:同步到服务器之前无法启动空闲监视器

javascript - 当属性为 0 或以下时从数组中删除对象 - Angular

javascript - JSZip 循环?

javascript - 使用 Iron Router 发布帖子时出现问题