4

Ember 1.13.10

I wanted to try out the closure actions, so I defined the a route:

import Ember from 'ember';

export default Ember.Route.extend({
  actions: {
    doSave() { ... }
  }
});

and the template:

{{my-component onSave=(action 'doSave')}}

But I get the error message: An action named 'doSave' was not found in (generated test.index controller).

However it is defined on the route. Given the fact that Controllers are kind of deprecated in Ember I would expect that the action should be defined on the route instead of the controller. Is there a specific reason why the closure actions should be defined on the controller?

Willem de Wit
  • 8,604
  • 9
  • 57
  • 90
  • Closure actions communicate with the controller if you want to bubble it up to the route you ll need to have an action on your controller that sends it up. – Patsy Issa Nov 23 '15 at 09:22
  • @Kitler Do you know if that is documented somewhere? – Willem de Wit Nov 23 '15 at 09:29
  • Afaik [closure actions](http://alexdiliberto.com/posts/ember-closure-actions/) aren't documented at the moment pending routable components. – Patsy Issa Nov 23 '15 at 09:57
  • I think controllers will be replaced by components but the actions and other logical stuff of application will not be in route.. – kristjan reinhold Nov 23 '15 at 10:00
  • They will be replaced but until routable components land controllers are your go to place. – Patsy Issa Nov 23 '15 at 10:02
  • Yeah but the stuff that was in controllers will next be in routeable component not route.. – kristjan reinhold Nov 23 '15 at 10:03
  • Possible duplicate of [How to call an action on a route using closure actions?](http://stackoverflow.com/questions/31101296/how-to-call-an-action-on-a-route-using-closure-actions) – Patsy Issa Nov 23 '15 at 18:16

1 Answers1

7

Closure actions communicate with the controller not the route, once routable components land they will replace controllers.

In your case if you wish to bubble the action you will have to send it from the controller.

Patsy Issa
  • 11,113
  • 4
  • 55
  • 74