0
我想在一個區域追加一個觀點,但我得到一個錯誤說:木偶 - 無法追加到區域
undefined is not a function
這裏是我的模板:
<div id="container"></div>
<script id="my-layout" type="text/html">
<h2>Hello!</h2>
<div id="menu"></div>
<div id="content"></div>
</script>
<script id="menuTemp" type="text/template">
<p>I am from Menu</p>
</script>
這裏是我的腳本:
var MenuView = Backbone.View.extend({
template:_.template($('#menuTemp').html()),
initialize:function(){
this.render();
},
render:function(){
this.$el.html(this.template);
return this;
}
});
container = new Backbone.Marionette.Region({
el: "#container"
});
MyLayout = Backbone.Marionette.LayoutView.extend({
template: "#my-layout",
regions: {
menu: "#menu",
content: "#content"
}
});
// Show the "layout" in the "container" region
layout = new MyLayout();
container.show(layout);
layout.menu.show(new MenuView().render().el); //not working
任何人都可以幫我解決這個問題嗎? 在此先感謝。
您需要使用木偶視圖而非骨幹視圖。 – 2014-09-06 18:53:39