aslagle / reactive-table

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

reactiveTable collection does not work without settings #299

Open pihentagy opened 8 years ago

pihentagy commented 8 years ago

The second html will not show any players (aslagle:reactive-table@0.8.16)

Players = new Meteor.Collection("players");

if (Meteor.isClient) {
  Template.leaderboard.helpers({
    players : function () {
      return Players;
    },

    tableSettings : function() {
      return {
          collection: Players.find(),
          fields: [
            { key: 'name', label: 'Full Name' },
            { key: 'score', label: 'Score' }
          ]
      };
    },
  });
}

// On server startup, create some players if the database is empty.
if (Meteor.isServer) {
  Meteor.startup(function () {
    if (Players.find().count() === 0) {
      var names = ["Ada Lovelace",
                   "Grace Hopper",
                   "Marie Curie",
                   "Carl Friedrich Gauss",
                   "Nikola Tesla",
                   "Claude Shannon"];
      for (var i = 0; i < names.length; i++)
        Players.insert({name: names[i]});
    }
  });
}
<head>
  <title>Leaderboard</title>
</head>

<body>
  <div id="outer">
    {{> leaderboard}}
  </div>
</body>

<template name="leaderboard">
  <div id="table">
    {{> reactiveTable settings=tableSettings }}
    {{> reactiveTable collection=players }}
  </div>
</template>
aslagle commented 8 years ago

I haven't been able to reproduce this. I tried this exact example in a new meteor app and both tables worked. I did see it once adding a table to an existing app, but when I restarted the app both tables worked and I couldn't reproduce it again - adding and removing the tables didn't cause any problems. Were you seeing the bug consistently?

pihentagy commented 8 years ago

I am not able to reproduce using meteorpad (http://meteorpad.com/pad/cStoP8qbt4gjBPv4s/reactive-table)

pihentagy commented 8 years ago

Neither can I reproduce it on another machine. But where I reproduced it, I can still reproduce it in a fresh new project. What could went wrong?