How to call an action in the view from built-in text helper (action=...)?


I am fairly new to Ember and so am probably overlooking something obvious, or making a simple error.

I am trying to build a “self-contained” view to build an understanding of the view-layer. (I’ll look at Components soon.)

The {{action}} helper can target actions which reside in the view.


  A.MyView = Ember.View.extend({
    actions: {
      myViewAction: function() { console.log('H, W!'); }

  {{action 'myViewAction' target='view'}}

How can I call this view-residing action using the action property of a built-in helper?

E.g., Something like (does not work): {{textarea action='view.myViewAction'}}

I have tried quite a few variations on the notation for the “action= …” property.

What seems interesting is that the above ... action='view.myViewAction' usage does not cause a “nothing handled…” failure, although the function is not called [on click; as I’d expect, as that’s the default event]. It appears that Ember is finding the action but not calling it, OR, is not finding it AND not logging the lookup failure.

If I change the code to:

{{textarea escape-press='view.myViewAction'}}

Ember will indeed log a “nothing handled…” lookup error when I press ESC.

I have a JSbin demonstrating my experiments here:

(The JSbin view has an array property of paragraphs, which can be on-click loaded into a textarea for editing. I want to update the loaded paragraph with the edited content from the textarea. I realize I could do this with a controller.)

Any advice or comments are appreciated.

Thank you, Richard


I don’t think this is supported, textareas and inputs are themselves components (isolated views that’s context (controller) is itself. They have no knowledge of what is outside them besides what you pass in.

In your case, I would make a component that wraps the text area and thus catches the action in the wrapper context.

It’s best practice these days to use components over views.


Thanks for your reply!

Yes, I’m trying to do this with a component now. However, I am [still] stumped. I suspect my question would be more appropriate for StackOverflow and will post there. (I’ve prepared another JSbin.)