i want a loading template to appear before the site has all data to be rendered.
And after the serverside Method gives me the Data(from an API [async]) via Meteor.call i want to load the correct layout.
I tried many ways found on Google which describe similar but not exatcly the same problem. Including the way to define a function with ready handle, also doesn′t work. I can′t get it running.
i don′t want to use Collections because this is user specific Data.( i think this is not efficient to make a collection for each user [no logged in users], or do i miss something) Is this possible?
Here my Code. The console logs 2 befor 1.
Router.route('/search/:term',{
name: 'search',
loadingTemplate: 'loading',
waitOn : function(){
var term = this.params.term;
//i think here has be something differnet either with return subscribe or function with ready-handle
Meteor.call('search',term,function(err, response) {
Session.set('shops', response);
console.log(1);
});
},
action : function(){
console.log(2);
this.render();
}
});
Template.search.helpers(
{
"shops" : function(){
return Session.get('shops');
}
}
);
Server Side Method returns an Array.
Thanks for help
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…