使用下划线模板。循环通过骨干集合:
<% _.each(venues, function (venue) { %>
<tr>
<td class="text-muted"><%= venue.get('city') %></td>
<td class="text-muted"><%= venue.get('name') %></td>
<td class="text-muted"><%= venue.get('live') == true ? "Yes" : "No" %></td>
<td class="text-muted">$0.00</td>
<td class="blank controls">
<a href="#"><span class="icon icon-edit"></span><span class="text-hide">Edit</span></a>
</td>
</tr>
<% }); %>
我明白了:
Uncaught TypeError: Cannot call method 'get' of undefined
答案 0 :(得分:1)
如果场地是Backbone.Collection,那么它将混合所有下划线迭代方法。
尝试:
<% venues.each(function (venue) { %>
<tr>
<td class="text-muted"><%= venue.get('city') %></td>
<td class="text-muted"><%= venue.get('name') %></td>
<td class="text-muted"><%= venue.get('live') == true ? "Yes" : "No" %></td>
<td class="text-muted">$0.00</td>
<td class="blank controls">
<a href="#"><span class="icon icon-edit"></span><span class="text-hide">Edit</span></a>
</td>
</tr>
<% }); %>