When you use this.sendAction('actionName') , you activate the action that you need to catch on the component / controller using actions
//controller/route/component.js actions: { actionName: function() { //Do something } }
If you want to send this chain, you will have to call sendAction('') again on the component / controller and catch it again on the parent device (etc.).
In another approach, this.get('action')() uses closing actions, which are regular javascript functions. As far as I know, this is the preferred way to trigger actions in Ember 1.13.X. One neat thing that closure actions have is that you can have return values. This means that you can have something like this:
//a controller actions: { saveResult() { return this.get('model').save(); //notice the return (which returns a promise) } } //some template that uses the controller above {{a-component save=(action 'saveResult')}} // Passes the saveResult action to the component //a-component.js actions: { someAction: function() { this.attrs.save().then(() => { //Do something with the return value }); } }
You can write a lot about closing actions, but others are written much better than I could, so I recommend the following articles:
And if you are new to the whole DDAU (Data Down Actions Up) concept, I really recommend Sam 's article on the concept in general.
Update: there is also an addon (linked in @locks comments) that allows closing actions to create route bubbles .
source share