发送动作到父组件? [英] Send actions to parent component?

查看:143
本文介绍了发送动作到父组件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个这样的模板:

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

当我点击 the-row 时,会触发一个动作( selectRow )。

我希望 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.

如何更改此行为?

推荐答案

在您的表中您的收益表应该产生 the-table 的上下文: {{yield this}} 。然后,您应该使用目标属性从 the-row 中定位表。

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}}

示例: http://emberjs.jsbin.com/pizilunaqi/edit? html,js,输出

这篇关于发送动作到父组件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆