Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ember.js/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ember.js 数据批量创建有很多关系_Ember.js_Ember Data - Fatal编程技术网

Ember.js 数据批量创建有很多关系

Ember.js 数据批量创建有很多关系,ember.js,ember-data,Ember.js,Ember Data,我正在开发的应用程序有这样一个事件模型 App.Event = DS.Model.extend({ title: DS.attr('string'), ... tests: DS.hasMany('App.Test') }); 现在我有了一个EventController来创建和保存一个新记录,其中this.set('content',App.Event.createRecord())this.get('model').save() 只需保存title属性就可以了,但现

我正在开发的应用程序有这样一个事件模型

App.Event = DS.Model.extend({
    title: DS.attr('string'),
    ...
    tests: DS.hasMany('App.Test')
});
现在我有了一个
EventController
来创建和保存一个新记录,其中
this.set('content',App.Event.createRecord())
this.get('model').save()
只需保存title属性就可以了,但现在我还希望能够通过模式对话框保存hasmall关系(例如test)。
我通过
{{outlet modal}}
加上相应的控制器创建该对话框,类似于stackoverflow上的一些答案。因此,我似乎能够使用
ObjectController

App.TestController = Em.ObjectController.extend({
    needs: ['event'],
    init: function(){
        var event = this.get('controllers.event').get('content')
        this.set('content', event.get('test').createRecord());
    }
});
老实说,我还没有对代码进行完整的测试,如果这样做有效的话,但看起来确实如此。因此,模板有一个相应的表单来填写详细信息。现在我想要的是后面的
ArrayController
,模板中的一个按钮“再添加一条”,然后将另一条记录推送到测试模型中,模板通过以下模板代码自动添加第二个表单:

{{#each controller}}
    ...form...
{{/each}}
如果您需要更多了解我的实现,请查看我昨天发布的这个问题:
希望您能理解这个问题,如果不是,我很乐意澄清。

我应该更彻底地完成测试。即使是单一的创作也不能完全发挥作用。但无论如何,这个问题仍然存在。如果我取得任何重大进展,我将发布更多。这是一个有趣的问题。如果您找到解决方案,请发回。