実装したいものの謙虚なモックアップを編集します
私はそのようなビューを定義しました:
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、 の3 つのコレクションがありordersます。そして、それぞれを別々のテーブルとして挿入したいと思いtab-paneます。モデルを に渡すことに関しては、それらを でラップし、後者を単にオブジェクトの一部として渡して表示GridViewContainerできると思います。次は何ですか?composite modeloptionsGridViewContainer
Product、Order、Categoryモデルにはさまざまなプロパティがあり、さまざまな編集フォームがあり、おそらくイベント処理があります。これにより、特異性がもたらされます。[EntityName]ListViewコレクションごとに使用してから、GridViewContainerビューに追加する必要がありますか?
ASIDE 私は、、、、、およびサーバー側で使用
jquery.jsします。使わないunderscore.jsbackbone.jsrequire.jsASP.NET MVC 4Marionette.js