I'd like to transition to a template but reloading the page content through a JSON request.
In other words, I load initially my index template through a getJSON
request and then I go to another template where I modify some data. Later, I'd like to return to my initial template through an action handler with the the same getJSON
request (it'll return another data different from the first one).
App.IndexRoute = Ember.Route.extend({
model: function() {
return $.getJSON("myurl");
},
actions: {
goto: function(){
$.getJSON("myurl");
this.transitionTo('index');
}
}
});
I'm able to transition to my template and to do a new JSON request but the data I see is the initial one. This only works if I click F5
because ember renders the template with the first getJSON
call from model function.
EDIT:
I've reached a solution but I'd like to know if there is another better one without reloading the page.
App.IndexRoute = Ember.Route.extend({
model: function() {
return $.getJSON("myurl");
},
actions: {
goto: function(){
this.transitionTo('index').then(function(){location.reload(true)});
}
}
});
Thanks in advanced!