Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy does my Meteor templates stop rendering when removing autopublish and manually publish/subscribing collections?
    primarykey
    data
    text
    <p>Since I turned off autopublish, as one should as its unrealistic in the real world, my templates stopped rendering collections (#each seems to loop over nothing). I've set up a manual publish/subscribe for the collection, and I can see the local collection has items in it when I log it to the console, yet the template fails to render the items. </p> <p>Is there anything I need do to when manually sub/pub-ing collections in order to keep the template's auto updating nature?</p> <p>Here's a diluted test case I've created:</p> <pre><code>// client Col = new Meteor.Collection('testcol'); // I have tried wrapping this in autosubscribe as well: Meteor.subscribe('testcol', function() { return Col.find(); }); Template.hello.items = function() { var col = Col.find(); if (col) { console.log("Test items" , col); return col.fetch().items; } } // server if (Meteor.is_server) { Col = new Meteor.Collection('testcol'); Meteor.publish('testcol', function() { return Col.find(); }) } // bootstrap: Meteor.startup(function () { if (Col.find().count() &lt; 5) { for (var i=0; i&lt;5; i++) { Col.insert({ title: 'Test ' + i, items: [ {title: 'item 1', value:true}, {title: 'item 2', value:false}, {title: 'item 3', value:true} ] }); } } }) // Template &lt;head&gt; &lt;title&gt;test&lt;/title&gt; &lt;/head&gt; &lt;body&gt; {{&gt; hello}} &lt;/body&gt; &lt;template name="hello"&gt; &lt;h1&gt;Where did the data gone to?&lt;/h1&gt; Items from the test collection: &lt;UL&gt; {{#each items}} &lt;LI&gt; ITEM: {{title}} {{/each}} &lt;/UL&gt; &lt;/template&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload