2014-09-10 205 views
0
define([ 
'jquery', 
'underscore', 
'backbone', 
    'app', 
    'models/sessionmodel', 
    'views/home/homeview', 

], function(
    $, 
    _, 
    Backbone, 
    app, 
    SessionModel, 
    HomeView 
){ 
    AppRouter = Backbone.Router.extend({ 

    initialize: function(options){}, 

    routes : { 
     ''   :'showhome', 
    }, 

    showhome : function(){ 
     this.show(new HomeView()); 
    }, 


    }); 

    return AppRouter; 

}); 

而這裏是我的主,這是第一次打擊每骨幹標準。我有一個名爲創建一個空的對象,並返回其應用的另一個文件...骨幹路由器似乎沒有正確擴展路由器

require.config({ 
paths: { 
jquery: 'libs/jquery/jquery-1.8.2', 
underscore: 'libs/underscore/underscore-min', 
backbone: 'libs/backbone/backbone-1.0.0-min', 
text: 'libs/require/text', 
router: 'router', 
app: 'app' 
}, 
shim: { 
    jquery: { 
     exports: '$' 
    }, 
    underscore: { 
     exports: '_' 
    }, 
    backbone: { 
     deps: ["underscore", "jquery"], 
     exports: "Backbone" 
    } 
} 
}); 

require(['app','router', 'models/sessionmodel'], function(app, AppRouter, SessionModel) { 

    app.router = new AppRouter(); 
    app.session = new SessionModel(); 
    app.session.checkAuth({ 

     complete: function(){ 
      Backbone.history.start(); 
     } 
    }); 
}); 

當我控制檯登錄此,路由器丟失其默認的方法(特別是瀏覽,但除了其他人一樣開,關,觸發器等)。

回答

0

你必須初始化它:var router = new AppRouter();

+0

我在主文件添加,我實例化approuter。對不起,謝謝。 – 2014-09-10 13:25:10

2

看來你不檢查記錄對象的__proto__屬性:enter image description here