0
https://github.com/marionettejs/backbone.marionette/blob/master/docs/marionette.view.md骨干牵线木偶中的视图如何知道与哪个模型相关联?
在这个例子中:
<script id="my-template" type="text/html">
I think that <%= showMessage() %>
</script>
MyView = Backbone.Marionette.ItemView.extend({
template: "#my-template",
templateHelpers: {
showMessage: function(){
return this.name + " is the coolest!"
}
}
});
model = new Backbone.Model({name: "Backbone.Marionette"});
view = new MyView();
view.render(); //=> "I think that Backbone.Marionette is the coolest!";
我试图分析这个代码,并根据我的骨干的了解,你必须指定模型视图与相关。我尝试了解Marionette的观点,并且我不知道文档的哪一部分,或者在这个示例中显示了该视图如何知道this
引用了新创建的模型。或者这只是一个错字?
啊我希望它是。如果不是,我会很困惑。感谢您的快速回复! – corroded