Send actions to parent component?

℡╲_俬逩灬. 提交于 2019-12-11 13:14:48

问题


I've a template like this:

{{#the-table}}
   {{#the-row selectedRow=selectedRow selectRow="selectRow"}}
     <td>something</td>
   {{/the-row}}
{{/the-table}}

When I click on the-row, an action (selectRow) is fired.
I would expect the-table to receive the action, but instead it's the parent view/component the receiver.

How can I change this behavior?


回答1:


Inside your the-table your yield statement should yield the context of the-table: {{yield this}}. And then you should target the table from the-row using the target attribute.

{{#the-table as |table|}}
   {{#the-row selectedRow=selectedRow selectRow="selectRow" target=table}}
     <td>something</td>
   {{/the-row}}
{{/the-table}}

Example: http://emberjs.jsbin.com/pizilunaqi/edit?html,js,output



来源:https://stackoverflow.com/questions/33389578/send-actions-to-parent-component

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!