I\'m getting a collection of records and placing them in a Template, having them rendered {{#each}} and I want to display a loading icon until the last DOM node
I do it yet another DIY way. Map an index/rank onto your cursor and then check that index against a count of the same query in your .rendered callback:
items: function() {
return Items.find({whatever: whatever}).map(function(item, index) {
item.rank = index + 1;
return item;
});
}
Template.stuff.rendered = function() {
if(this.data.rank === Items.find({whatever: this.data.whatever}).count()) {
// Do something cool like initializing a sweet
// JS plugin now that ALL your template instances
// are all rendered
$("#coolplugindiv").coolJSPluginInit();
}
}
I'm sure it's slightly more taxing on the server, but it works. Thought I'm curious about template.lastNode and if there's some way to use that to have the same effect.