2013-04-29 99 views
0

我敢肯定,這可能是超級平凡的東西。骨幹路由器,頁面加載導航不會發生

一切都像一個魅力除了路由器沒有更新頁面加載,路線:後事件永遠不會觸發。與文件加載相關的所有路由器都運行。

我正在犯的任何可能導致此錯誤的基本錯誤?

window.Router = new Backbone.Router(obj = { 
    routes: { 
    '':'home', 
    'page/:id':'post' 
    } 
}); 

Router.on('route:home', function(value){ 

    $(window).scrollTop(); 
}); 

Router.on('route:post', function(value){ 

    window.pageHandler.scrollToSectionWithName("#"+value); 

});  

Backbone.history.start({pushState:true}); 

回答

0

嘗試啓動骨幹歷史不pushState的:

Backbone.history.start();

檢查骨幹文檔中有關History-start得到什麼可能是可能的錯誤的一些提示。

0

嘗試添加無聲

Backbone.history.start({ pushState: true, silent: false }); 
+0

當'silent'沒有作爲一個選項傳遞,它被視爲是'FALSE'。所以,你在這裏做的建議與OP已經做的沒什麼不同:'Backbone.history.start({pushState:true});' – Louis 2016-09-07 17:54:57

+0

true,sorry。我已經把它設置爲真,並在同一個問題上運行。設置爲false爲我固定它..大聲笑 – walteronassis 2016-09-07 19:11:40