0
我正在編寫一個非常簡單的骨幹模型/視圖顯示。基本上有一個叫做shortDescription的json字段,它應該被顯示成一個。但是,無論我在視圖中設置了什麼值,我的代碼都不會顯示爲空。骨幹視圖不顯示模型的值
這裏是代碼,我在哪裏做錯了?
的html代碼:
<div id="itemDetailContainer"></div>
<script type="text/template" id="itemDetailTemplate">
<h3> <% shortDescription %> < /h3>
</script>
的Javascript:
ItemModel = Backbone.Model.extend({
initialize: function() {}
});
ItemDetailView = Backbone.View.extend({
initialize: function() {
this.$el = $("#itemDetailContainer");
this.template = _.template($("#itemDetailTemplate").html());
_.bindAll(this, "render");
this.render();
},
render: function() {
this.$el.html(this.template(this.model.toJSON()));
return this;
}
});
var it = new ItemModel({"shortDescription": "short"});
var v = new ItemDetailView({model: it});
http://jsfiddle.net/Cpn3g/886/