I have an action:
{{action create target=\"controller\"}}
which I have targeted to the bound controller (rather than the router) like this:
In fact, this is not Ember idiomatic. From what I know, and what I have learnt from Tom Dale himself, here are some remarks about that code:
You should definitely put the action inside the router, and transitionTo accordingly.
Hope this will help.
UPDATE
First example (close to your sample)
In the appropriated route:
saveAndReturnSomewhere: function (router, event) {
var store = router.get('store'),
boardName = event.context; // you pass the (data|data container) here. In the view: {{action saveAndReturnSomewhere context="..."}}
store.createRecord(App.Board, {
title: boardName
});
store.commit();
router.transitionTo('somewhere');
}
Refactored example
I would recommend having the following routes:
show
: displays an existing item,edit
: proposes to input item's fieldsInto the enclosing route, following event handlers:
createItem
: create a new record and transitionTo edit
route, e.geditItem
: transitionTo edit
routeInto the edit
route, following event handlers:
saveItem
: which will commit store and transitionTo show
route, e.g