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,保存块(属于多维数据集)时,会保存belongsTo关系,但多维数据集的hasMany关系不会保存。创建块后,不会向服务器发送PUT请求以更新多维数据集 块模型: export default DS.Model.extend({ name: DS.attr(), description: DS.attr(), cube: DS.belongsTo('cube') }); 立方体模型: export default DS.Model.extend({ name: DS.attr(

保存块(属于多维数据集)时,会保存
belongsTo
关系,但多维数据集的
hasMany
关系不会保存。创建块后,不会向服务器发送PUT请求以更新多维数据集

块模型:

export default DS.Model.extend({
  name: DS.attr(),
  description: DS.attr(),
  cube: DS.belongsTo('cube')
});
立方体模型:

export default DS.Model.extend({
  name: DS.attr(),
  description: DS.attr(),
  blocks: DS.hasMany('block', { async: true })
});
保存块:

  var name = this.get('name');
  var description = this.get('description');
  var cube = this.store.peekRecord('cube', this.model.id);

  if (!name) {return;}

  this.store.createRecord('block', {
    name: name,
    description: description,
    cube: cube
  })
  .save()
  .then(function() {
    this.resetForm();
    var name = slugify(this.model.get('name'));
    this.transitionToRoute('cubes.show', this.model.get('id'), name);
  }
  .bind(this));

不要使用
this.model.id
尝试
this.get('model.id')
。还有一点很重要,那就是不要使用
.bind(this)
。您可以使用箭头函数,如
。然后(()=>{//您可以访问此引用;})
而不是
this.model.id
尝试
this.get('model.id')
。还有一点很重要,那就是不要使用
.bind(this)
。您可以像
一样使用箭头函数。然后(()=>{//您可以访问此引用;})