【发布时间】:2011-09-26 06:19:45
【问题描述】:
我有以下backbone.js 客户端模板:
<script id="calleeTemplate" type="text/x-jquery-tmpl">
<tr style="background-color: ${StatusColour}">
<td class="responder">${ContactFullName}</td>
<td class="status" style="width:200px">${Status}</td>
<td class="replied">${Replied}</td>
<td class="wauto">${Response}</td>
</tr>
</script>
为了能够绑定到这些属性,我有以下视图的渲染方法:
App.Views.Callees = Backbone.View.extend({
initialize: function () {
},
el: $('#calleesStatuses'),
render: function () {
var col = _.map(this.collection.models, function (item) {
return item.attributes;
});
$('#calleesStatuses').html('');
$('#calleeTemplate').tmpl(col).appendTo(this.el);
}
});
我必须使用下划线_.map 函数从模型中提取属性。我认为这是因为主干使用.get("property") 来提取属性值。
这对我来说似乎不对,我做错了什么吗?
【问题讨论】:
标签: backbone.js