编辑 我想要实现的简陋模型
我已经定义了这样一个视图:
define(['jquery', 'underscore', 'backbone', 'text!_templates/gv_container.html', 'bootstrap/bootstrap-tab'],
function($, _, Backbone, htmlTemplate, tab) {
var GridViewContainer = Backbone.View.extend({
id: 'tab-panel',
template: _.template(htmlTemplate),
events: { 'click ul.nav-tabs a': 'tabClicked' },
tabClicked: function(e) {
e.preventDefault();
$(e.target).tab('show');
},
render: function() {
this.$el.append(this.template);
return this;
}
});
return GridViewContainer;
}); // define(...)
视图的模板如下所示:
<ul class="nav nav-tabs">
<li class="active"><a href="#products">Products</a></li>
<!-- other tabs -->
</ul>
<div class="tab-content">
<div class="tab-pane active" id="products">
<!-- table with rows like { title, few more properties, edit|remove links } -->
</div>
<!-- other panes ... -->
</div>
最初我以为我可以使用它(同时作为所有集合的通用模板)。
目标
我有三个集合:products
, categories
, orders
. 我想将它们中的每一个作为表格插入到单独tab-pane
的 s 上。至于将模型传递给GridViewContainer
我认为我可以将它们包装在 a 中composite model
,然后简单地将后者作为options
对象的一部分传递给GridViewContainer
查看。下一步是什么?
Product
, Order
,Category
模型有不同的属性,有不同的编辑形式和可能的事件处理。这带来了特异性。我应该使用[EntityName]ListView
每个集合然后将其附加到GridViewContainer
视图吗?
除了 我在服务器端使用
jquery.js
,underscore.js
,backbone.js
,require.js
, 和。ASP.NET MVC 4
我不使用Marionette.js