I\'m having trouble with a callback after the #each
has finished. I have a template named \"content\":
{{#if T
I had a similar problem and after a lot of searching found the following solution. I tried using Tracker
, onRendered
and other tricks, none of them worked. This could be considered more of a hack, but works. Unfortunately can't remember where I found this solution initially.
Start with your template, but add an template tag after your each
.
{{#if Template.subscriptionsReady}}
{{#each currentData}}
{{/each}}
{{doneTrigger}}
{{else}}
Loading...
{{/if}}
Then define a helper that returns null.
Template.content.helpers({
doneTrigger: function() {
Meteor.defer(function() {
// do what you need to do
});
return null;
}
});
You can read more about Meteor.defer()
here, but it is equivalent to using a 0 millisecond setTimeout
.