Hello,
I'm not sure if this is related to #11442 or not, but based on the documentation I had thought setupController should get called on route refresh calls:
https://github.com/emberjs/ember.js/blob/v2.0.1/packages/ember-routing/lib/system/route.js#L1048
Refresh the model on this route and any child routes, firing the
`beforeModel`, `model`, and `afterModel` hooks in a similar fashion
to how routes are entered when transitioning in from other route.
The current route params (e.g. `article_id`) will be passed in
to the respective model hooks, and if a different model is returned,
`setupController` and associated route hooks will re-fire as well.
Given the following example, that doesn't appear to be the case:
import Ember from 'ember';
export default Ember.Route.extend({
model: function(params) {
// this gets called on initial load and on refresh
return this.store.find('my-model', params.my_model_id);
},
setupController: function(controller, model) {
// this only gets called on initial load and *not* on refresh
this._super(controller, model);
// do stuff that should happen on refresh
},
actions: {
refreshRoute: function() {
this.refresh();
}
}
});
Any insight? Thanks!
I think it's because the model isn't changing.
Thanks @teddyzeenny. You're correct.
If this is the case then, should an explicitly reloaded model trigger setupController another time? It currently does not.
e.g.
import Ember from 'ember';
export default Ember.Route.extend({
model: function(params) {
// this gets called on initial load and on refresh
// explicitly reload the model from the server
return this.store.findRecord('my-model', params.my_model_id, { reload: true });
},
setupController: function(controller, model) {
// this only gets called on initial load and *not* on refresh
this._super(controller, model);
// do stuff that should happen on refresh
},
actions: {
refreshRoute: function() {
this.refresh();
}
}
});
@bjubinville perhaps put that code into an ember-twiddle or jsbin and check an older version to see if setupController was called in the past but isn't now.
@pixelhandler, will do
I am also running into this on ember-cli 1.13.8. I think this is quite a bad bug. setupController should always fire on refresh(), just as stated in the docs.
+1 and @pixelhandler , it was working since I'm using Ember and this is quite a long time.
Is this still relevant?
@utilityboy I do not this this is a bug in a supported version of Ember. If this was something in version 1.13 it should have been fixed by now.
I'll close this out for now, please reopen if you find this issue in a current Ember release, including the LTS version, thanks!
Just today I stumbled upon this bug too*. As you refresh your route, and the model is exactly the same (i.e. the model has the same id), the setupController hook will not be called.
*Both Ember 2.16.2 (LTS) and Ember 2.18.2
-- Edit --
Workaround: this.transitionTo('current.routeName', this.get('currentModel.id'))
Hi! I am facing the same issue in Ember 3.0.0. The this.refresh() method doesn't trigger the setupController() hook 鈽癸笍.. Kindly assist me to get through this馃檪
@jevanlingen I'm curious if you can pin down the source code for that:
no model changes no setupController invoked? Thank you.
@jevanlingen I'm curious if you can pin down the source code for that:
nomodelchanges nosetupControllerinvoked? Thank you.
I was able to figure out myself. Here are the findings.
# Flow
_proto9.finalizeTransition = function finalizeTransition(transition, newState) {
=> this.setupContexts(newState, transition);
=> _proto9.setupContexts = function setupContexts(newState, transition) {
=> this.routeEnteredOrUpdated(currentRouteInfos, partition.entered[i], true, transition);
=> _proto9.routeEnteredOrUpdated = function routeEnteredOrUpdated(currentRouteInfos, routeInfo, enter, transition) {
=> route.setup(context, transition);
=> _proto.setup = function setup(context, transition) {
=> this.setupController(controller, context, transition);
See the triple equal sign === !==, which only check equality by reference.

Most helpful comment
I was able to figure out myself. Here are the findings.
See the triple equal sign

===!==, which only check equality by reference.