Reputation: 21
I'm having a weird issue in ember js with sending actions from one route/controller to another route. The action never hits the other route's action handler. I can send actions from controller to controller, from same controller to same route, but not an additional hop from one controller/route to another route handler.
Ultimately what I'm trying to achieve is sending an action from one route users.new to another route, users.login. The action isn't handled in users.login's controller so I was assuming that it would bubble to the users.login route action handler.
Any help is very much appreciated!
Upvotes: 0
Views: 2011
Reputation: 21
Sending actions from peer routes does not work. The solution is to create a session service.
Upvotes: 1
Reputation:
Actions bubble to controllers and then to its route and then the ancestors of that route. They are not used for communication across/between routes.
The question is, what do want the action to do? It sounds quite a bit like you really want to transition to a route, instead of sending an action to it or its controller. If you want to pass parameters along with the transition, you can do so using query parameters.
If you could provide more details or existing code, we might be able to give you some specific code fragments.
If for some reason you are real sure you want to communicate between routes and controllers, you can use Ember events. You send them using this.trigger('event')
and listen for them using object.on('event', handler)
. However, I doubt if you need this for the problem you are trying to solve.
I have no idea how session services are supposed to address this problem. Normally, a session service is how you would keep track of session (user) information in a way accessible to very controller/route etc.
Upvotes: 1