Where to import Aldeed:Tabular


I’m using https://github.com/longshotlabs/meteor-tabular (Amazing Meteor wrapper on jQuery DataTables).

Tables are supposed to be initialized in common code.

I’ve had it in imports/startup/lib/MY_TABLE.js. This worked like a charm in terms of client-server interaction to fetch rows and whatnot.

Edit: This is then imported in a imports/startup/lib/index.js (a module that imports all other shared code)

I had some console.time statements before/after the new Tabular.Table initialization in the MY_TABLE.js.

The actual {{> tabular ...}} template call gets called when the client accesses a specific route. The actual data loads, pub/sub, pagination, etc… of the table only happens when this route is accessed. That’s good.

The issue is, that the new Tabular.Table is still being called every time the client refreshes or accesses the app. This makes sense given the way I’m importing the module.

However, I’m now noticing this causes a bug with DataTables saveState (a plugin to save search terms, columns, etc…). saveState uses LocalStorage, and now, multiple keys are created for that table depending on which route the user is on. This causes conflicts.

So - any idea on where in Common Code I should load MY_TABLE so that it only gets called when the client accesses the specific route.