1

I'm using multiple tabular-tables in Meteor to display sets of partitioned data on the same page. Each occurrence of the tabular appears in a separate template instance, but they all refer to the same table. I have a template that looks as follows:

<template name="parentTemplate">
....
{{#each folders}}
  {{> childTemplate}}
{{/each}}
....
</template>
<template name="childTemplate">
  {{> tabular table=Table class="..." selector=selector}}
</template>

folders returns a set of partitions for the data, selector just returns {folderId: _id}

My Tabular.Table constructor is pretty simple, the only thing of note is:

changeSelector(selector, userId){
    const ret = _.extend(selector, {status: "active"});
    console.log(JSON.stringify(ret));
    return ret;
}

the console.log part returns what I would expect, for each table a different folderId. When I put the logged selector into mongodb, I get the expected partition for each table, however each table shows me the same set of data as the first table. Additionally, when I click "next page" all the tables update to show the partition that should be displayed in the final table. I've checked that all the tabular table elements in the HTML have unique Id's.

Am I just using tabular-tables incorrectly?

EDIT: After some tinkering, I found a potential solution, but it isn't clean, so I'd still like to hear people's thoughts. What I did was declare a meteor method as follows:

Meteor.methods({Table: function(){return new BlahTable(...);})

This is executed on the client and server, creating the relevant tabular table in both locations, then I use the newly created table in {{>tabular...}}

Zack Newsham
  • 2,810
  • 1
  • 23
  • 43

0 Answers0