I have a loading template. need to load loading template
whenever client subscribe data from the server.
Template.myTemplate.onCreated(function() {
var loading;
Template.instance().autorun(function() {
if (!Template.instance().subscriptionsReady()) {
loading = Blaze.render(Template.loading, document.getElementsByTagName('body')[0]);
} else {
Blaze.remove(loading);
}
});
});
1st time Blaze.render
and Blaze.remove
works fine. But again if i do more subscription, It keep on adding loading
template. How do I remove template from the DOM when else part executes?
if (!Template.instance().subscriptionsReady()) {
if (Template.loading.isRendered) {
return;
}
// if not rendered to DOM, then do render
} else {
Blaze.remove(loading);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.