I have a route, and the data that want to return for that route needs to come from an AJAX REST request to a server, the response of this request should be used as the template data so I can loop over the results in the template.
What is the easiest way to achieve this? I'd need this to either be a synchronous call inside my data function that get's passed into the template. Like this:
Router.map(function() {
this.route('test', {
path: '/test',
data: function() {
var templateData = { title : 'My Redeemed Rewards', menu : 'ion-navicon', parent : 'myRewards' }
// Make syncronous request and extend the template data object with the json response
return templateData;
}
});
});
Or have it be an asynchronous request and have the template re-render when the data is available. How would i get the template to redraw in this case?