2014-09-06 76 views
3

在我的應用程序中,我使用Marionette的擴展名爲Backbone。使用該腳本Backbone Marionette - 在佈局調用中拋出錯誤擴展

Uncaught TypeError: Cannot read property 'extend' of undefined 

而且我想我的頭,並追加內容與頁腳包裝元素...:我得到的第一個錯誤是

但是根本未工作.. 。

這樣做的正確方法是什麼?

模板:

<div id="wrapper"></div> 
<script id="layout-template" type="text/template"> 
    <section>  
     <navigation id="menu">ABC</navigation>  
     <article id="content">123</article> 
    </section> 
</script> 

腳本:

AppLayout = Backbone.Marionette.Layout.extend({ 
    template: "#layout-template", 
    regions: { 
     menu: "#menu", 
     content: "#content" 
    } 

}); 

var layout = new AppLayout(); 
$('#wrapper').html(layout.render().el); 

這裏是Live Demo

任何一個可以幫助我使我的所有元素包裝器嗎?

+2

在'2.0'版本中,木偶改變'Layout'爲'LayoutView',所以它應該是'Backbone.Marionette.LayoutView.extend' – 2014-09-06 13:35:48

回答

2

你應該用這種方式:

AppLayout = Backbone.Marionette.LayoutView.extend({ 
    template: "#layout-template", 
    regions: { 
     menu: "#menu", 
     content: "#content" 
    } 

}); 

凱爾李約瑟所說,LayoutView改變Layout