在此示例中无法正常返回按钮。始终返回数据库状态。
App.Router = Ember.Router.extend({
enableLogging: true,
root: Ember.Route.extend({
index: Ember.Route.extend({
route: '/',
redirectsTo: 'databases'
})
}),
databases: Ember.Route.extend({
route: '/databases',
show: Ember.Route.transitionTo('database'),
connectOutlets: function(router) {
var applicationController = router.get('applicationController');
applicationController.connectOutlet('databases');
App.router.get('databasesController').loadDatabases();
}
}),
database: Ember.Route.extend({
route: "/databases/:db_name",
connectOutlets: function(router, db) {
var applicationController = router.get('applicationController');
applicationController.connectOutlet('database', db);
}
})
})
链接到操作'show':{{ action show db href=true }}
STATEMANAGER: Entering root ember-1.0.0-pre.2.min.js:18 STATEMANAGER: Sending event 'navigateAway' to state root. ember-1.0.0-pre.2.min.js:18 STATEMANAGER: Sending event 'unroutePath' to state root. ember-1.0.0-pre.2.min.js:18 STATEMANAGER: Sending event 'routePath' to state root. ember-1.0.0-pre.2.min.js:18 STATEMANAGER: Entering root.index ember-1.0.0-pre.2.min.js:18 STATEMANAGER: Entering databases
然后我点击'show'动作
STATEMANAGER: Sending event 'show' to state databases. ember-1.0.0-pre.2.min.js:18 STATEMANAGER: Entering database
现在按浏览器的后退按钮
STATEMANAGER: Sending event 'navigateAway' to state database. ember-1.0.0-pre.2.min.js:18 STATEMANAGER: Sending event 'unroutePath' to state database. ember-1.0.0-pre.2.min.js:18 STATEMANAGER: Sending event 'routePath' to state database.
为什么它是州数据库?我想这是因为show动作中的transitionTo('database')
。成功显示项目列表,单击一个并获取详细视图的黄金路径是什么,而不是单击“返回”并返回列表视图?
答案 0 :(得分:1)
根据Mehul Kar的评论,路线应该嵌套。