Display hasMany content in parent template


#1

How to do it?

This does not work:

Template:

"[script type=“text/x-handlebars” data-template-name=‘index’] {{#each model}} {{#each transaction in transactions}} tx {{/each}} {{/each}} [/script]

Application: window.App = Ember.Application.create(); App.ApplicationAdapter = DS.FixtureAdapter; App.Account = DS.Model.extend({ title: DS.attr(‘string’), transactions: DS.hasMany(‘transaction’) });

App.Account.FIXTURES = [ { id: 1, title: ‘Your account’, transactions: [1, 2, 3] }];

App.Transaction = DS.Model.extend({ date: DS.attr(‘date’), name: DS.attr(‘string’), amount: DS.attr(‘number’), paidWith: DS.attr(‘string’), account: DS.belongsTo(‘account’) });

App.Transaction.FIXTURES = [ { id: 1, date: new Date(2012, 04, 17), name: ‘Item 1’, amount: 10, paidWith: ‘credit card’, account: 1 }, { id: 2, date: new Date(2012, 04, 01), name: ‘Item 2’, amount: 50, paidWith: ‘cash’, account: 1 }, { id: 3, date: new Date(2012, 03, 28), name: ‘Item 3’, amount: 100, paidWith: ‘bank transfer’, account: 1 }]; App.IndexRoute = Ember.Route.extend({ model: function() { return this.store.findAll(‘account’); } });


#2
 transactions: DS.hasMany('transaction')

change to

transactions: DS.hasMany('transaction', {async : true})

#3

Thank you for help, this works well.