Dave W.
Dave W.

Reputation: 1596

Ember.TextField target the view from inside a component

I have a component that contains a view. This view uses the {{input}} helper to render an Ember.TextField.

I have an action defined on the child view (not the component), which needs to be triggered on the escape-press action emitted from the TextField. How do I target the current view using the {{input}} helper?

Here's a jsbin with the whole setup.

Upvotes: 0

Views: 141

Answers (1)

rharper
rharper

Reputation: 2438

To tell a Component to send actions to a particular target object, set it's targetObject property:

{{input escape-press="alert" targetObject=view placeholder="Press <esc> when focused"}}

I've updated the jsbin here to show it working.

(Also, your original jsbin had a typo in the WrapperView - action instead of actions)

Upvotes: 3

Related Questions