Take the 2-minute tour ×

In the latest documentation of Ember it's sayed that the action helper will trigger a method on the current action.

   {{#if isExpanded}}
      <div class='body'>{{body}}</div>
      <button {{action "draw"}}>Draw</button>
      <button {{action "expand"}}>Show More...</button>

How to tiggrer an action on the associated view ? I need to do some action on the view like drawing on the canvas. But, it can't figure out how to get the reference of the view associated to current controller.

share|improve this question
add comment

1 Answer

up vote 4 down vote accepted

{{action draw target="view"}} should work.

share|improve this answer
Thanks! It works. The documentation also say that we can handle the action in the router. Is it always possible to get the reference of the active views there ? –  jrabary Jan 16 '13 at 10:45
Yes this should be possible using the container api, but it seems an anti-pattern. Could you explain more what you would do in the question ? –  sly7_7 Jan 16 '13 at 10:49
In the previous version of the router we did router.get('something') to get the reference of the controller or view that we want to deal with. The question is : how to do this with the latest API ? –  jrabary Jan 16 '13 at 10:55
from an event handler in the route, you can do this.controllerFor('controllerName'), or this.container.lookup('view:viewName'). But for me this is bad smell, but if it satisfies you, use it –  sly7_7 Jan 16 '13 at 10:57
add comment

Your Answer


