jeudi 26 avril 2018

How to dry route actions with component in EmberJS

(EmberJS 2.14)

I want to have DRY apps with ember, however, it seems it is impossible to do with route actions. When I try to use a component for the button triggering the action it fails :

new.js :

  export default Ember.Route.extend({
      model() {.....},
      actions: {
          saveStuff(newStuff) {
            newStuff.save().then(() => this.transitionTo('stuffs'));
          }

new.hbs



Error :

Assertion Failed: An action named 'saveStuff' was not found in (generated Stuffs.new controller)

I have the same problem with the delete action and the update action. I can't resign myself to have the same code and template lines in every routes and views that needs it.




Aucun commentaire:

Enregistrer un commentaire