ember.js - emberData bulk create hasMany relationship -
the app working on has event model this
app.event = ds.model.extend({ title: ds.attr('string'), ... tests: ds.hasmany('app.test') });
now have eventcontroller
create , save new record this.set('content', app.event.createrecord());
this.get('model').save();
saving title attribute works fine, want able save hasmany-relationships (e.g. test) via modal-dialog. creating dialog via {{outlet modal}}
plus according controller, similar answers here on stackoverflow. seem able modal work objectcontroller
and
app.testcontroller = em.objectcontroller.extend({ needs: ['event'], init: function(){ var event = this.get('controllers.event').get('content') this.set('content', event.get('test').createrecord()); } });
to honest, haven't tested code yet full if works, seems is. template has according form fill in details. have arraycontroller
in , button in template 'add 1 more' sort of pushes record test-model , the template automatically adds second form via following template code:
{{#each controller}} ...form... {{/each}}
if need see more of implementation check out question posted yesterday: create , display emberdata models on same route/resource hope understand question, if not happy clarify.
Comments
Post a Comment