Use async routing… This kind of routing helps you when you want Javascript to puase and wait for you to do somehting like make an API request and get data before continuing…
Read through the guide to understand it…
sample
{
path: '/some-path/:param',
async: function (routeTo, routeFrom, resolve, reject) {
var router = this;
var app = router.app;
var param = routeTo.params.param;
app.dialog.preloader();; //Preloader
app.request({
url: API_ENDPOINT,
dataType: 'json',
method: 'GET',
cache: false,
crossDomain: true,
success: function (data) {
app.dialog.close(); //close preloader
resolve(
{
componentUrl: './pages/some-page.html'
},
{
context: {
info: data,
}
}
);
}
},
error: function () {
app.dialog.close();
app.dialog.alert('Failed To Make Request!');
reject();
}
});
}
},
if idsouscat in your response is idsubcat above in your request code, the on your template it is easy to construct your URL there too easily i your {{#each}}...{{else}}...{{/each}}
Thank you Max.
The thing is when I putt my async code before tabs[{}] the app make a call to my api and it’s works.
When I putt async code in tabs router I have no call to api on the console.
Do you think is impossible to make async call in tabs ?
Routable tabs should accept all forms of routes, async is just something, ‘hey, before you conclude on where to direct the user, please, let me do something first, will tell you when am ready’… This way, all routing is paused, and the app waits for you to do anything, until you resolve() or reject ()… So It really should work… Let me ready myself and test with my own code…
Just a last question : is there possible to charge tabs content via async one time ?
Ex : on the opening, the app charge all the async tabs content and when the user navigate no content is refreshed ?