samedi 29 mars 2014

Template rendered callback fired only once with Meteor 0.8 when Session variable changes


Vote count:

0




I'm stuck with a problem since I upgraded to 0.8.0. The Template rendered is not being fired anymore (except the first time).


I followed the recommendations as in: http://ift.tt/1hLu7kx


This didn't helped, and so I finally made this small piece of code (by modifying the new2 example).


The main difference is that the update is triggered by a Session variable change instead of a DB change.


This perfectly shows the problem, as rendered is fired only twice with this example:


client/each.js



Items = new Meteor.Collection("items", {connection: null});

Template.list.items = function () {
return (Session.get('items') || 'None')
};

var renderCount = 1;
var logRender = function () {
console.log("rendered #" + renderCount);
renderCount++;
};

Template.list.rendered = function () {
logRender();
};

Template.justName.rendered = function () {
logRender();
};

setInterval(function () {
Session.set('items', {name: Random.choice(["one", "two", "three"])});
}, 1000);


client/each.html



<body>
{{> list}}
</body>

<template name="list">
{{#with items}}
{{> justName}}
{{/with}}
</template>

<template name="justName">
{{name}}
</template>


How can I do to get the rendered properly fired with content is updated?


Thanks,



asked 41 secs ago






Aucun commentaire:

Enregistrer un commentaire