JavaScript Meteor Collections are not displaying

I'm following the book Getting Started With Meteor and I'm really not getting far because simple errors keep blocking me.

At this point in time I've started writing the initial app in the book in which we make a new global connection.

Lists = new Meteor.Collection("lists");

We then add some data to that collection.

lists.insert({Category:"DVDs", items: {Name:"Item Name",Owner:"me",LentTo:"Internet"}})

I can verify that the data is entered by checking in the console

lists.find({}).count(); //returns 2 
lists.findOne({Category:"DVDs"}) //returns the DVD category

However when I try to display this content in the DOM nothing is displayed.

<div id="categories-container">
  {{> categories}}
</div>

<template name="categories">

   <div class="title"><h3>My Stuff</h3></div>

    <div id="categories">
       {{#each lists}}
          <div class="category">
            {{Category}}
         </div>
       {{/each}}
    </div>
</template>

This displays only my Title. I get no errors in the browser console or the command line console. Not sure how to diagnose this.

Answer:1

I am pretty sure the reason is because you have

    Lists = new Meteor.Collection("lists");

But then you do:

    lists.insert({Category:"DVDs", items: {Name:"Item Name",Owner:"me",LentTo:"Internet"}})
    lists.find({}).count(); //returns 2 
    lists.findOne({Category:"DVDs"}) //returns the DVD category

But you should do

    Lists.insert({Category:"DVDs", items: {Name:"Item Name",Owner:"me",LentTo:"Internet"}})
    Lists.find({}).count(); //returns 2 
    Lists.findOne({Category:"DVDs"}) //returns the DVD category

Because it is case sensitive. Then in your Template helper do a Lists.find({}) and you should be good to go.

Answer:2

Did you define a template helper to display your content?

You may need:

Template.categories.lists = function() {
  return Lists.find({});
};

Check out the documentation for specifics:

http://docs.meteor.com/#templates

For faceting on categories, you'll probably want to set a reactive session value.

Answer:3

I'd like to get the number of characters between the start of a container and the cursor (including tags characters). Example : <div id="contentEditor" contenteditable="true"> <p>...

I'd like to get the number of characters between the start of a container and the cursor (including tags characters). Example : <div id="contentEditor" contenteditable="true"> <p>...

I'm fairly new to Node.js and am having trouble understanding the way to go about loading libraries or files, in runtime. Apparently, it is a bad idea to load files in runtime using Node.js's native "...

I'm fairly new to Node.js and am having trouble understanding the way to go about loading libraries or files, in runtime. Apparently, it is a bad idea to load files in runtime using Node.js's native "...

I'm trying to run JavaScript code with PHP variables. In the HTML it is OK. The script runs and the subpage is loaded within the content (div). But when I try to run the script with PHP variables, ...

I'm trying to run JavaScript code with PHP variables. In the HTML it is OK. The script runs and the subpage is loaded within the content (div). But when I try to run the script with PHP variables, ...

  1. javascript variables with dollar sign
  2. javascript variables with underscore
  3. javascript variables with functions
  4. javascript variables with examples
  5. javascript variables with text
  6. javascript variables with name
  7. javascript string with variables
  8. javascript regex with variables
  9. javascript class with variables
  10. javascript array with variables
  11. javascript object with variables
  12. javascript math with variables
  13. javascript json with variables
  14. javascript eval with variables
  15. javascript alert with variables
  16. javascript string with variables inside
  17. javascript template with variables
  18. javascript calculate with variables
  19. javascript with session variables
  20. javascript addition with variables

Is there a way to convert the following jQuery method to pure javascript? var myProps = $(".interp").map(function () { return this.id; }).get(); I do not know how many objects will be available ...

Is there a way to convert the following jQuery method to pure javascript? var myProps = $(".interp").map(function () { return this.id; }).get(); I do not know how many objects will be available ...

  1. jquery pure js
  2. jquery vs pure javascript
  3. jquery to pure javascript converter online
  4. jquery animate pure javascript
  5. jquery find pure javascript
  6. jquery to pure javascript converter
  7. jquery load pure javascript
  8. jquery append pure javascript
  9. jquery closest pure javascript
  10. jquery extend pure javascript
  11. jquery ajax pure javascript
  12. jquery vs pure javascript performance
  13. jquery ready pure javascript
  14. jquery offset pure javascript
  15. jquery html pure javascript
  16. jquery scrolltop pure javascript
  17. jquery each pure javascript
  18. jquery trigger pure javascript
  19. jquery selector pure javascript
  20. jquery css pure javascript