新しい Project オブジェクトを正常に保存した後、別のビューへの移行をどのように処理すればよいですか? 検証に合格したら、@transaction をコミットし、Projects インデックス ビューに移行します。
コントローラ:
DA.ProjectsController = Em.ArrayController.extend
createProject: (project) ->
@transaction = DA.store.transaction()
p = @transaction.createRecord(DA.Project, project)
validation_errors = p.validate()
if validation_errors
DA.displayError validation_errors
else
@transaction.commit()
### What should be here to transition the route/view? ###
router.transitionTo('projects') # Like this?
DA.get('router').send('projects') # This?
###################################################
ルーター:
DA.Router = Em.Router.create
location: 'history'
root: Em.Route.extend
index: Em.Route.extend
route: '/'
redirectsTo: 'projects'
projects: Em.Route.extend
route: '/projects'
index: Em.Route.extend
router: '/'
connectOutlets: (router) ->
router.get('applicationController').connectOutlet('projects', DA.Project.find())
showProject: Em.Route.transitionTo('project')
project: Em.Route.extend
route: '/projects/:project_id'
connectOutlets: (router, project) ->
router.get('applicationController').connectOutlet('project', project)
newProject: Em.Route.extend
route: '/projects/new'
connectOutlets: (router) ->
router.get('applicationController').connectOutlet('projectsNew')
doProjects: (router) ->
router.transitionTo('projects')
doProjectsNew: (router) ->
router.transitionTo('newProject')