简体   繁体   中英

Using collection helpers in meteor tabular

I'm displaying table data using Meteor 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

I installed dburles:collection-helpers extension and add helper in common code section:

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冲突,后者定义了自己的助手

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM