在我的应用程序中,我使用Marionette
,即Backbone
的扩展。我得到的第一个错误是:
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);
这是实时演示
有人帮我把我所有的元素都渲染到包装器上吗?
您应该使用这种方式:
AppLayout = Backbone.Marionette.LayoutView.extend({
template: "#layout-template",
regions: {
menu: "#menu",
content: "#content"
}
});
正如Kyle Needham所说,将Layout
更改为LayoutView
。