我试图在使用mustache.js构建的模板上呈现主干集合.问题是我无法在模板中获得模型的cid.我的代码是
<div class="phone span4">
<h5> Phone Appointments</h5>
{{ _.each(slots, function(slot) { }}
{{ if(slot.aptType == "P"){ }}
<h6 cid="{{=slot.cid}}" aptId="{{=slot.aptId}}"> {{=slot.beginTime}} - {{=slot.endTime}} </h6>
{{ } }}
{{ }); }}
</div>
Run Code Online (Sandbox Code Playgroud)
从上面的代码中,我可以得到aptId,beginTime和end Time,但不是Cid.如何在模板上渲染模型时从集合中获取模型的Cid?
我从视图中看到的渲染方法如下所示
render:function(){
var template = _.template($("#slot-display-template").html());
compiledTmp = template({slots: this.collection.toJSON()})
this.$el.append(compiledTmp);
}
Run Code Online (Sandbox Code Playgroud)
使用cid作为模型的唯一标识符也有任何缺点吗?
提前致谢 !!!