Using Blaze on meteor is not working the way tutorials say it will

84 Views Asked by At

My sidebar needs to load the names and paths out of the the nodes collection. my publication.js

Meteor.publish('nodes', function(){
return Nodes.find();

}); my nodes_find.js in the server file with the publication.js file

if(Nodes.find().count() === 0){
Nodes.insert({
    name: "Example Node",
    path: "ExampleNode"
});
Nodes.insert({
    name: "Node 2",
    path: "ExampleNode"
});
Nodes.insert({
    name: "Node 3",
    path: "ExampleNode"
});

} the Html block for the nodes and paths to show up on

<template name="sidebar">
<ul class="sidebar-nav" id="sidebar" role="navigation">     
 <div class="nodes">
  {{#each nodes}}
  <li>
    <a href="{{path}}">
      {{name}}
    </a>
  </li>
  {{/each}}
  </div>
</ul>

and finally the sidebar.js file

Template.sidebar.helpers({
nodes: function(){
    return Nodes.find();
}

});

although all I get is 4 paper thin tabs with no names and no paths. I have gone over the Discover Meteor book and done the practice and have seen how they use it and looked on many forumns and have seen this exact code work. Is there something I am missing?

2

There are 2 best solutions below

2
On

I think you have forgotten to subscribe your publication. Or if your autopublish is installed then you don't need to subscribe. And please check your client console if your data is really getting passed in the client or not.

0
On

@Faysal Ahmed thank you for suggesting the console tests. I had completely overlooked that idea. I had not though that the database would have kept the old database from way back when I first made the app. So I researched it and found that using Meteor reset would help with clearing the database. Now I have what I want on my site thank you very much for the idea.