Roman Kolesnikov
Roman Kolesnikov

Reputation: 12147

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?

Upvotes: 2

Views: 1499

Answers (2)

Roman Kolesnikov
Roman Kolesnikov

Reputation: 12147

Finally I found the problem: TabulatTables use collection transformer dburles:collection-helpers to call necessary function, but it confilcts with perak:joins that defines his own helpers

Upvotes: 1

mwarren
mwarren

Reputation: 2469

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);

Upvotes: 2

Related Questions