I have a template, task_list, that looks like this:
{{#each tasks}}
{{> task}}
{{/each}}
Template.task_list.tasks returns a collection and in the ui, it seems to take a bit of time to load.
While the collection is loading, I’d like to show a loading indicator.
Any ideas on how I might be able to do that?
BTW, I did try the templates’ rendered event on task_list template, however it gets fired before the list is actually loaded. I also tried using rendered on the task template but it seems to never get called.
Meteor 1.0.4 update: Now that template-level subscriptions are available and the preferred pattern to using iron:router or standalone subscriptions,
Example:
This is better than having a generic loading template for the whole page, because the loading section is localized to the part of the page that actually has new data.
Pre-Meteor 1.0.4:
The idea is to pass an onReady function to
Meteor.subscribe:Then, make your template depend on the
tasksLoadedsession variable. In the client JavaScript:In your template:
UPDATE: With iron-router you have a direct option to specify a
loadingtemplate which will be displayed while the subscription is loading.