I'm trying to get a graph redrawn every time I hit a certain controller/route. There are other pages where inputs are changed and the graph needs to redraw when the 'modeller' page is navigated to. Subsequent input changes on the modeller page cause a redraw but the graph is initially scaled incorrectly each time you navigate to it. So I need to do a redraw based on all the new inputs the moment you arrive on the 'modeller' page.
export default Ember.Controller.extend({
calculator: Ember.inject.service(),
needs: ['modeller'],
init: function() {
this.drawCharts();
},
})
So the init() is only called once when the app starts, but I need something to call it whenever the 'modeller' route is hit.
I've tried adding this to the controller but to no avail:
doSomething: function() {
console.log("currentPath");
return;
}.observes('currentPath'),
And I've tried to trigger it from the router:
var Router = Ember.Router.extend({
location: config.locationType,
doSomething: function() {
console.log("didTransition in router");
this.get('controllers.modeller').init();
return;
}.on('didTransition'),
});
... which almost works - the "didTransition in router" is logged but I can't then reference the controller. It says "this.get(...) is undefined"??
Any help appreciated. Thanks.
Aucun commentaire:
Enregistrer un commentaire