と を含む CompositeView が<header>
あり<tbody>
ます。<tbody>
で使用するために に追加されたコレクションから特定のデータが必要<header>
です。具体的には、コレクション内のレコードの TOTAL NUMBER と、すべてのモデルの TOTAL COST を表示する必要があります (各モデルにはamount
、 のようなドル値の属性があります54.35
)。
どうすればこれを行うことができますか?
すべての相対コードは次のとおりです。
/*
* Layout
*/
var AppLayout = Backbone.Marionette.Layout.extend({
template: "#customer-view",
regions: {
card: "#customer-card",
quotes: "#customer-quotes",
orders: "#customer-order-history"
}
});
Show.Layout = new AppLayout();
Show.Layout.render();
/*
* ItemView
*/
Show.HistoryItemView = Backbone.Marionette.ItemView.extend({
tagName: "tr",
template: "#customer-history-item"
});
Show.HistoryItemsView = Backbone.Marionette.CompositeView.extend({
template: "#customer-history-wrapper",
itemView: Show.HistoryItemView,
itemViewContainer: "tbody"
});
/*
* Items
*/
var customer_orders = Customers.request("customer:orders", UserID);
var customer_orders_view = new Show.HistoryItemsView({
collection: customer_orders
});
Show.Layout.orders.show(customer_orders_view);
…そしてテンプレート:
<script type="text/template" id="customer-history-wrapper">
<div class="module collapsible">
<header>
<hgroup>
<h2>Order History</h2>
</hgroup>
<div class="results">
<div class="left"><strong><%= NUMBER OF RECORDS %></strong> Orders</div>
<div class="right">$ <%= TOTAL COST OF RECORDS %></div>
</div>
</header>
<div class="module-content no-pad">
<table class="simple-table six-up" cellpadding="0" cellspacing="0">
<thead>
<tr>
<th>Date</th>
<th>Licensee</th>
<th>Company</th>
<th>Order</th>
<th class="numeric">Total</th>
<th class="cta"> </th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
</div>
</script>
<%= NUMBER OF RECORDS %>
このデータを<%= TOTAL COST OF RECORDS %>
挿入する必要がある場所です。
私が得ることができる助けに感謝します!!