I have a controller (KbRelatedGroupController
) that is loaded via a {{render}}
helper in a template.
In the controller's action, if I do this.get('target')
, it returns a reference to the parent controller for the page (KbShowController
).
If I call .target
on that, I get a reference to Discourse.Router
, which is no good to me.
What I want is a reference to a KbShowRoute
, and that is what I expected since .target
is supposed to produce the Route when called from a controller is it not?
Really confused here. Why is it so hard to get a reference to the current route from a controller?
The way I see it, you're not supposed to. You can let the action bubble up to the route:
App.KbShowRoute = Ember.Route.extend({
...
actions: {
something: function() {
console.log('called second');
}
}
});
App.KbShowController = Ember.Controller.extend({
...
actions: {
something: function() {
console.log('called first');
}
}
});
see docs
You could:
this.controllerFor(this.routeName).sendAction('..', ...)
to call a different action (or part of the action) in the controller.I hope this helps you!