2012-10-11 54 views
0

你好,我正在創建一個骨幹網頁,我用控制器來激活一些視圖。骨幹保持URL刷新f5

我有這樣的控制器:

var AppRouter = Backbone.Router.extend({ 
    routes: { 
     "":"main", 
     "your":"yourpost", 
     "random" : "randompost", 
     "featured" : "featuredpost", 
     "sponsored" : "sponsoredpost", 
     "post/:pos" : "post", 
     }, 
     main : function() { 
     console.log("MAIN_VIEW"); 
     main_view.render(); 
     }, 
     yourposts : function() { 
     console.log("YOUR_VIEW"); 
     yourpost.refresh(); 
     yourpost.render(); 
     }, 
    ... 
    // Instantiate the router 
    var app_router = new AppRouter(); 
    // Start Backbone history a neccesary step for bookmarkable URL's 
    Backbone.history.start(); 

當我在URL中有一些這樣的:

... /網絡/ index.html的#你

和我按F5鍵,網頁瀏覽器寫:

.../web/index.html#

我的問題是,當我按f5時如何保持url的值?

謝謝!

+1

從來沒有這個問題..你使用什麼瀏覽器? –

+0

我在fedora 17中使用Chrome –

+0

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

回答

0

我的代碼有一個失敗,我做了一個會話方法,將信息保存在backbone var中,當我刷新時,如果沒有變量,則重定向到主頁面。我必須修改登錄方法才能刷新頁面而不會出現問題。

對不起,謝謝!