简体   繁体   English

Emberjs:deleteRecord()不一致地更新模型

[英]Emberjs: deleteRecord() doesn't update model consistently

(To Repro: Click into a list, add a task, try to remove that task.) (要复制:单击进入列表,添加一个任务,尝试删除该任务。)

I have an app where I can create multiple lists of tasks, each task can be commented on. 我有一个应用程序,可以在其中创建多个任务列表,每个任务都可以进行评论。

I am having trouble getting consistent behavior when deleting a record. 删除记录时,我无法获得一致的行为。 I can delete a record within an already existing model. 我可以删除现有模型中的记录。 However once I create a Record, I can't seem to delete it. 但是,一旦创建记录,似乎就无法删除它。 But then once I leave a page (transition to another Route) and come back, I can delete again. 但是,一旦我离开页面(过渡到另一条路线)并返回,就可以再次删除。 Is this a problem with .save()? .save()是否有问题?

JSBin: http://jsbin.com/oDOsoqA/3/edit JSBin: http : //jsbin.com/oDOsoqA/3/edit

It's the {async : true} on the hasMany tasks. 这是hasMany任务上的{async:true}。 Honestly this functionality is a little shaky (My guess is that it should be nailed down and functionality will be a bit more apparent once they've hit a solid 1.0). 老实说,此功能有些不稳定(我猜想应该牢记此功能,一旦达到稳定的1.0,功能将更加明显)。

You can get rid of the push and change the links to the model and it all works, but I'm not sure about your async necessities. 您可以摆脱压力,更改与模型的链接,它们都可以使用,但是我不确定您的异步需求。

http://jsbin.com/oDOsoqA/4/edit http://jsbin.com/oDOsoqA/4/edit

addTask : function(){
  var foo = this.store.createRecord('task', { 
    description : '',
    list : this.get('model'),
    comments : []  
  });
  //this.get('tasks').pushObject(foo);
  foo.save();
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM