I want the page to refresh automatically after updating the controller model property.
I follow this advice: How to reload the current route in Ember.js?
So, I have the "runSimulation" action method in my controller, at the end of which I have this line:
this.send("sessionChanged");
In the linked route, I have:
actions: { sessionChanged: function() { console.log('YEAH'); var transition = this.refresh(); console.log(transition); } }, renderTemplate: function(controller, model) { console.log('DINGDONG'); var model = this.currentModel; if (model.simulation.params == undefined) { this.render('gobernador/crear-simulacion'); } else { this.render('gobernador/show-simulacion'); } }
I could see that YEAH is being printed (this means: the sessionChanged event dispatched by the controller was successfully captured by the handler in the route object) ... but I do not see DINGDONG being printed.
I am using ember-cli and I have log transition enabled. I could see this in my javascript console:
Transitioned into 'gobernadores.gobernador.simulacion'
(what is expected). I assume that going to "gobernadores.gobernador.simulacion" will cause a renderTemplate call (which for some reason is not happening here).
What might give us a hint here is perhaps the value of the "transitional" object returned from the "update". In my case, it gives:
{state: TransitionState, intent: C, **isActive: false,** router: Router, data: Object, resolvedModels: Object…} _visibleQueryParams: Objectdata: Object, handlerInfos: Array[4], intent: C, params: Object, pivotHandler: Class, promise: PromisequeryParams: Object, resolveIndex: 4,resolvedModels: Objectrouter: Routersequence: 4, state: TransitionStatetar, getName: "gobernador.simulacion"}
This "isActive" is false. Could this be the reason? If so, why is "isActive" incorrect?
I checked the Ember.Route :: refresh API document ( http://emberjs.com/api/classes/Ember.Route.html#method_refresh ) ...
Update the model on this route and on any child routes by running the beforeModel, model, and afterModel buttons in the same way that the routes will be entered when switching from another route. The current route parameters (for example, article_id) will be passed to the corresponding model hooks, and if another model is returned, setupController and its associated routes will also be restarted.
So ... maybe my question comes down to ...: what conditions must be met for the route update method to return the transition whose isActive is true?
I am using ember 1.10.0
Thanks, Raka
UPDATE
I put this link here ... just in case it gives some help in analyzing the situation: http://blog.trackets.com/2013/02/08/router-request-lifecycle.html