i have model plant , related model planting should have urls like:
/plants /plants/new /plants/some-plant-id/planting/new   the route add planting works in url , displays correct add form. problem submit action on planting/new not work.
console
ember.debug.js:19699 uncaught error: nothing handled action 'saveplanting'. if did handle action, error can caused returning true action handler in controller, causing action bubble. i guessing issue way constructed route in router.js not sure. there 1 controller- app/controllers/application.js minimal
here of code
app/routes/planting/new.js
import ember 'ember';  export default ember.route.extend({    model() {         return this.store.createrecord('planting');   },    actions: {      saveplanting(newplanting) {       console.log("trying save...");       newplanting.save().then(() => this.transitionto('planting'));     },      willtransition() {        //rollbackattributes() removes record store        //if model 'isnew'       this.controller.get('model').rollbackattributes();     }   } }); router.js
... this.route('plants', function() {   this.route('new');   this.route('edit', { path: '/:plant_id/edit' });    this.route('planting',  { path: '/plants/:plant_id/planting' },   function(){     this.route('new');   });  }); ... incidentally, template directories like
app/templates/plants app/templates/plants/new.hbs app/templates/plants/planting/new.hbs  //plantings dir in plants routes directories
app/routes/plants app/routes/planting what doing wrong?
i think problem want use action route in template.
in order should use route-action helper (https://github.com/dockyard/ember-route-action-helper).
otherwise action in controller :)
Comments
Post a Comment