【发布时间】:2013-02-07 15:52:29
【问题描述】:
有一组我想渲染到模板中现有<select> 元素的项目。我遇到的问题是视图总是将<option> 列表包装在DIV 标记中。我怎样才能只呈现<option> 列表而没有任何包装元素?
模板:
<script type="text/template" id="template-select">
<% _(elements).each(function(element) { %>
<option value="<%= element.id %>"><%= element.name %></option>
<% }); %>
</script>
查看:
myView = Backbone.View.extend({
template: template('template-select'),
render: function() {
this.$el.html(this.template({
elements: this.collection.toJSON()
}));
return this;
}
});
【问题讨论】:
标签: backbone.js