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