Meteor content not displaying

484 views Asked by At

I am having issues with either Flow Router or my template level subscriptions but the data is not being rendered on the page.

Just incase the issue isn't what I have pasted here I have included a link to the entire github repo: https://github.com/adjohnston/checkr-meteor

lib/routes.js

listRoutes.route('/:slug', {
  name: 'list',

  subscriptions: function (params) {
    this.register('singleList', Meteor.subscribe('singleList', params.slug));
  },

  action: function () {
    FlowLayout.render('mainLayout', {
      main: 'list'
    });
  }
});

server/publication/lists.js

Meteor.publish('singleList', function (slug) {
  return Lists.find({slug: slug});
});

client/lists/list.js

Template.list.helpers({
  singleList: function () {
    return Lists.find();
  }
});

client/lists/list.html

<template name="list">

  {{#if isSubReady}}
    {{#with singleList}}

      <h2>Name: {{name}}</h2>

    {{/with}}
  {{/if}}

</template>

Solution

Change returns Lists.find() to Lists.findOne() since the publication 'singleList' is only returning a single result.

client/lists/list.js

Template.list.helpers({
  singleList: function () {
    return Lists.findOne();
  }
});
1

There are 1 answers

2
Jeremy S. On BEST ANSWER

Try changing your singleList helper to a findOne:

Template.list.helpers({
  singleList: function () {
    var slug = FlowRouter.getParam("slug");
    return Lists.findOne({slug: slug});
  }
});

Right now you are trying to display the name property of a cursor, which is what find() returns. You also don't need {{#with singleList}} in your handlebars.