2012-12-11 110 views
0

在這個例子中無法獲取後退按鈕正常工作。始終返回到數據庫狀態。無法獲取後退按鈕正常工作在ember.js

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); 
    } 
    }) 
}) 

鏈接到行動 '秀':{{ 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 

然後我點擊 '顯示' 行動

 
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. 

爲什麼這是狀態數據庫?我想這是因爲transitionTo('database')在show action中。什麼是黃金通道成功地顯示項目列表中,單擊一個,並得到詳細視圖,比點擊「返回」,返回列表視圖?

+1

薩米,我會通過嵌套'databases'和'了'root'路線內database'路線開始。 – mehulkar

+0

真棒。你是對的! – Sammy

+0

不錯,很高興它的工作:) – mehulkar

回答

1

根據MEHUL嘉的評論,路線應該被嵌套。

+0

哈哈,我不認爲那是答案,但很高興知道它解決了這個問題。 – mehulkar