0

我是新來要求js和我使用佈局管理器的骨幹。我已經粘貼下面我的代碼,我沒能獲得佈局管理工作,我得到這個錯誤:使用requirejs加載LayoutManager中的問題

"Uncaught TypeError: Cannot call method 'extend' of undefined" 

在線路在使用佈局管理(Backbone.LayoutView.extend)

Main.js 

require.config({ 
paths: { 
    jquery: 'lib/jquery-1.9.1.min', 
    underscore: 'lib/underscore-min', 
    backbone: 'lib/backbone-min', 
    handlebars: 'lib/handlebars', 
    layoutManager : 'lib/backbone.layoutmanager' 
    mousewheel : 'lib/jquery.mousewheel.min' 
}, 
shim : { 
    'backbone' : { 
     deps: ['jquery', 'underscore' ], 
     exports: 'Backbone' 
    }, 
    'layoutManager' : { 
     deps: ['jquery', 'underscore', 'backbone'], 
     exports: 'LayoutManager' 
    }, 
    'mousewheel' : ['jquery'] 
} 

});

require(["jquery", "underscore", "backbone", "layoutManager", "handlebars","mousewheel", "common"],function($, _, Backbone, LayoutManager, Handlebars,mousewheel, App) { 


App.Views.HelloView = Backbone.LayoutView.extend({ 
    template : '#hello_tmpl1', 
}); 

App.Layouts.AppLayout = new BackBone.Layout({ 

    template : '#layout', 
    views : { 
     ".helloView" : new App.Views.HelloView() 
    } 
}); 

$('body').empty().append(App.Layouts.AppLayout.el.render()); 

}); 

Common.js 
    define(function(){ 
    var App = null; 
    App = { Models:{}, Views:{}, Collections:{}, Templates:{}, Router:{}, Layouts:{}}; 

    return App; 
}); 

回答

0
function($, _, Backbone, LayoutManager 

在這裏你的名字佈局管理。

App.Views.HelloView = Backbone.LayoutView.extend({ 

這裏您嘗試使用它作爲Backbone.LayoutView ......不存在(因此未定義)。嘗試

App.Views.HelloView = LayoutView.extend({ 

你這裏的骨幹VAR是從全球一個不同,認爲requirejs :)

+0

以及問題是我使用的是版本管理器的新版本(0.80),並在該LayoutView中除去。 – user1184100 2013-04-07 13:08:49

0

佈局管理器的新版本不使用「LayoutView」創建視圖。使用Backbone.Layout.extend({...})來創建你的視圖...玩得開心..;)