私は以下のItemView
テンプレートを持っており、顧客データ(firstName、lastName)で満たされており、をdivに追加したいと思います。Marionette.js ItemView - 地域に子ビューを置く
テンプレート
<script type="text/html" id="template-customer-details">
<h4><%= firstName %> <%= lastName %></h4>
<button class="edit">Edit</button>
<h5>Addresses</h5>
<div class="addresses">...</div>
</script>
レイアウトは、私はエラーを取得しています
Layout.Details = Backbone.Marionette.ItemView.extend({
template: '#template-customer-details',
regions: {
addresses: ".addresses"
},
serializeData: function() {
return this.model.attributes;
},
initialize: function() {
this.addressList = new App.Models.AddressList();
// Error!
this.regions.addresses.show(this.addressList);
this.bindTo(this, "render", this.$el.refresh, this.$el);
this.model.bind("change", this.render.bind(this));
}
});
は "キャッチされない例外TypeError:オブジェクト.addressesには方法は、 'show' がありません。"
ビューが読み込まれるまで待つ必要がありますか?
これはよく見えます:)表示したい場合はCompositeViewも使用できますか顧客データの下に2つのコレクション(住所用と連絡先用)、またはレイアウトを使用する必要がありますか? – Dennis
@Dennis - レイアウトでそれを使用する –
現在のバージョンが3.0の場合、CompsoiteViewのitemViewとitemViewContainerはchildViewとchildViewContainerである必要があります。 'item'の名前を 'child'に変更します。 http://marionettejs.com/docs/v2.4.7/marionette.compositeview.html#compositeviews-childview –