Ember.Component
は異なります - アクションを自動的にバブルしません。
follow-action
特定のケースでは、次のように、最初に-component でアクションを再送信し、次にuser-item
-componentで、次に -component で再送信する必要がありますuser-list
。
// template
{{user-list action="follow"}}
// component
...
actions: {
follow: function() {
this.sendAction() // The default action is 'action'
}
}
...
これは、完全にログに記録される変更された jsbin です:
http://emberjs.jsbin.com/wobawa/1/edit
余談ですが、Ember 2.0 では、コンポーネントのアクションにいくつかの新しい概念が導入されているため、これは少し簡単になります。詳細については、Ember 2.0 RFC を参照してください。
手動でバブルする必要を避けるためにできることは、コンポーネントのブロック構文を使用してコンテキストを保持し、そこにアクションを含めることです。
// my-controller.hbs
// The 'follow' action will be triggered in this context (the controller)
{{#my-component}}
{{#my-intermediate-component}}
<button {{action 'follow'}}>Follow!</button>
{{/my-intermediate-component}}
{{/my-component}}
これを示す jsbin を次に示します: http://emberjs.jsbin.com/juzuru/1/edit