dimanche 18 septembre 2016

Ember.js action bubbling but controller undefined in action

I have a route that has an afterModel hook.

afterModel: function(model, transition){
  transition.send('doInAppRoute');
}

I have an action in my application route:

doInAppRoute: function(){
  var controller = this.get('controller');
  controller.set('someProp', true);
}

When I allow the action to bubble from the route with the afterModel hook, I get the following error.

Error while processing route: embed Cannot read property 'set' of undefined TypeError: Cannot read property 'set' of undefined

If I put an action call to doInAppRoute in the application template, everything runs as expected.

If the action call to doInAppRoute bubbles, this.get('controller') in my application route is undefined. Why?

And how can this be changed so the bubbled action updates the application controller property?




Aucun commentaire:

Enregistrer un commentaire