aslagle / reactive-table

A reactive table designed for Meteor
https://atmospherejs.com/aslagle/reactive-table
Other
328 stars 137 forks source link

Table disappear #319

Open expeerd opened 8 years ago

expeerd commented 8 years ago

When page is loaded table disappear. There isn't table block in DOM. helper: Employers : function(){ return Workshop.findOne().employers; }

log of Workshop.findOne().employers : [ {userId: "MaKsSL2emcsud7mCk", role: 0, _id: "MaKsSL2emcsud7mCk"}, {_id: "8e4qgL4MjCPsbqpZR", role: null}, {_id: "8e4qgL4MjCPsbqpZR", role: null}, {_id: "8e4qgL4MjCPsbqpZR", role: null}, {_id: "8e4qgL4MjCPsbqpZR", role: null}, {_id: "8e4qgL4MjCPsbqpZR", role: null} ]

error from console: reactiveTable error: argument is not an instance of Mongo.Collection, a cursor, or an array

expeerd commented 8 years ago

typeof says that output is object, but Array.isArray is true

aslagle commented 8 years ago

The array should work, it must not be getting passed to the table.

Did you call the template like this: {{> reactiveTable collection=Employers}}?

If that doesn't work, does Workshop have a subscription? Maybe it's not ready when the table loads.

expeerd commented 8 years ago

Yes, I made so, and yes workshop have subscription, table had worked before I added second and others objects in array, then table has broken. It's reactive source if it's not ready table will be empty, but not disappear from DOM, I think so

aslagle commented 8 years ago

I can't tell what the problem might be from this. An array should work fine, but maybe there's another error happening somewhere else.

expeerd commented 8 years ago

I think table fall when trying to convert array to local collection, I think so because this logs in console, and then table disappear: Exception in template helper: MinimongoError@http://localhost:3000/packages/minimongo.js?af9eb9d7447544ca9b839a3dcf7ed2da2209b56c:95:20 insert@http://localhost:3000/packages/minimongo.js?af9eb9d7447544ca9b839a3dcf7ed2da2209b56c:599:25 http://localhost:3000/packages/mongo.js?3cfe0c5981c197df33036a37574850f057e934a6:667:52 http://localhost:3000/packages/aslagle_reactive-table.js?6383c35996c7ea32bbbce66d0b64d78e67e8f0c0:860:34 forEach@[native code] forEach@http://localhost:3000/packages/underscore.js?0a80a8623e1b40b5df5a05582f288ddd586eaa18:156:18 setup@http://localhost:3000/packages/aslagle_reactive-table.js?6383c35996c7ea32bbbce66d0b64d78e67e8f0c0:859:19 context@http://localhost:3000/packages/aslagle_reactive-table.js?6383c35996c7ea32bbbce66d0b64d78e67e8f0c0:1073:23 http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:2880:21 http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:1651:21 http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:2928:71 _withTemplateInstanceFunc@http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:3476:16 http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:2927:52 call@http://localhost:3000/packages/spacebars.js?7bafbe05ec09b6bbb6a3b276537e4995ab298a2f:172:23 http://localhost:3000/packages/aslagle_reactive-table.js?6383c35996c7ea32bbbce66d0b64d78e67e8f0c0:50:26 http://localhost:3000/packages/spacebars.js?7bafbe05ec09b6bbb6a3b276537e4995ab298a2f:264:25 http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:1865:22 _withTemplateInstanceFunc@http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:3476:16 http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:1864:54 _withCurrentView@http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:2197:16 Spacebars_with:anonymous@http://localhost:3000/packages/blaze.js?a5c324925e5f6e800a4c618d71caf2848b53bf51:1863:34 _compute@http://localhost:3000/packages/tracker.js?6d0890939291d9780f7e2607ee3af3e7f98a3d9c:327:36 _recompute@http://localhost:3000/packages/tracker.js?6d0890939291d9780f7e2607ee3af3e7f98a3d9c:346:22 _runFlush@http://localhost:3000/packages/tracker.js?6d0890939291d9780f7e2607ee3af3e7f98a3d9c:485:24 onGlobalMessage@http://localhost:3000/packages/meteor.js?43b7958c1598803e94014f27f5f622b0bddc0aaf:372:23

expeerd commented 8 years ago

It's magic.This table forks fine without any code modifications, I've just used another Mongo document with new data, but it will not be magic if something another didn't went wrong))) Another table broken when I changed data manually via console, and changing document don't solve problem. Probably tables are sensitive to the way how array was created.

aslagle commented 8 years ago

Maybe there's something in the array that can't be inserted into a minimongo collection. The package creates a new Mongo.Collection and inserts each element from the array, so if that causes an error it will break the table.