例としてHTMLタブバーを使用します。通常、ulとdivのリストがあります。私が発見したすべてのバックボーンとしては、など、 'エル'、 'tagNameを' で一つのノードのみでビューをリンク...2つ以上の好きなノードでバックボーンビューを作成するにはどうしたらいいですか?
HTMLのTabBar:
<div class=".tabbar">
<ul class=".tabbar-header">
<li><a href="#tab-cars">Cars</a></li>
<li><a href="#tab-houses">Houses</a></li>
</ul>
<div id="tab-cars" class=".tabbar-item">...</div>
<div id="tab-houses" class=".tabbar-item">...</div>
</div>
バックボーンコード:
window.TabBarView = Backbone.View.extend({
el: ???,
tabs: [],
render:function (eventName) {
// Render all tabs in this.tabs
_.each(this.tabs, function (item, position) {
// Render each tab with item.render()
}, this);
return this;
}
});
window.TabBarItemView = Backbone.View.extend({
el: ???,
initialize:function() {
this.model.bind("change", this.render, this);
this.model.bind("destroy", this.close, this);
},
render:function (eventName) {
// Render the tab header and tab content
return this;
}
});
TabBarViewにいくつかのTabBarItemViewを追加し、それぞれul.tabbar-header内にliノードを作成し、コンテンツとしてdiv.tabbar-itemを作成します。
ああ、私はコードを書き換えて、今はokです。書き換えは、ナビゲーション用とサブコンテンツ用の2つのサブビューを作成することにあります。そして、Tabbarviewは新しい/古いタブを管理します。そして、TabBarItemViewはdisapearedです。ありがとう。 –