1
votes

I have nested routes defined in my Ember app (Ember 2) as below;

this.route('main', function() {
  this.route('step1', function(){
        this.route('step1A');       
  });
});

Now I want to navigate to the child route & want to trigger the 'model' hook So I have

var routeName = 'main.step1.step1A';
self.transitionTo(routeName); //Tried Option1
self.get('controller').transitionToRoute(routeName); //Tried Option2

My question is while I do see the URL change, the 'model' hook does not get triggered.

How do I force the 'model' hook to be triggered ?

As per the doc, I think the rule is for routes with dynamic segments. But my route is a simple route.

1
I know this is not the best answer, but what if you loaded your model in setupController()? It is always run and as long as you can show no data first and update the template later, this could be one alternative.Pavol
Well...for some strange reasons, even the setupController hook is not getting executed !copenndthagen
What if you transitioned to the route "workflow.step1.step1A" using a parameter (plain parameter, like string, not an object) which would force ember hit the model() hook? You don't have to use it, of course.Pavol
The problem with no setupContoller() being fired could be that Ember generates it for you, if you don't have it. Do you have workflow.step1.step1A controller?Pavol
I do have that controller and also tried manually passing string 'workflow.step1.step1A'copenndthagen

1 Answers

0
votes

I stumbled upon the same problem today. I came up with following workaround:

this.transitionTo('main.step1.step1A');
this.get('router._routerMicrolib.currentHandlerInfos').findBy('name', 'main.step1.step1A').handler.refresh();