Fez Vrasta
Fez Vrasta

Reputation: 14815

Send actions to parent component?

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?

Upvotes: 1

Views: 1537

Answers (1)

Kingpin2k
Kingpin2k

Reputation: 47367

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

Upvotes: 2

Related Questions