I am working on an Ember app for training. I configured it on the user interface, where the parent route and the template at the first opening contain a table, for example, of today's elements in the column on the left, as well as the area on the right: information about the element, form for new / editing, search, etc.
The problem I ran into is that when saving a new item, the left table from the parent route is not updated with the new item. Could not find a way to get this route for the update. The closet I came using pushObject on the model.
template:
{{partial "things/table"}} {{outlet}}
router.coffee
@resource "items", -> @route "item", {path: "/:item_id"} @route "new", {path: "/new"}
route of objects:
ItemsRoute = Ember.Route.extend( model: -> @store.find 'item' )
new route:
ItemsNewRoute = Ember.Route.extend renderTemplate: -> this.render('items/form') model: -> @store.createRecord('item') setupController: (controller, model)-> controller.set('model', model)
Elements of the new controller:
ItemsNewController = Ember.ObjectController.extend( needs: 'items' actions: submit: -> @model.save().then(console.log('saved'(, console.log('failed')) cancel: -> @transitionTo('items') transitionAfterSave: (-> if @get('content.id') @transitionToRoute('items.item', @get('content')) ).observes('content.id')
source share