简体   繁体   English

模型的删除/更新记录在余烬数据中不起作用?

[英]Delete/Update record of model is not working in ember-data?

I have made simple CRUD program here . 在这里做了简单的CRUD程序。

But on click of delete (here i am trying to delete first record of model) it is not deleting any record,it is throwing error 但是在单击删除时(这里我正在尝试删除模型的第一条记录)它没有删除任何记录,而是抛出错误

Uncaught TypeError: Object function () {..} has no method 'deleteRecord' 

Can anyone help me to solve this issue i am struggling on this issue from last 2 days? 最近两天有人可以帮助我解决这个问题吗? I have posted my code here . 我已经在这里发布了我的代码。

I have edited my fiddle to add functionality of create record (here) It is adding blank records in table. 我已经编辑了小提琴以添加创建记录的功能(在此),它正在表中添加空白记录。 Can anyone tell me how to add/create record in this case? 在这种情况下,谁能告诉我如何添加/创建记录?

    savecontact: function(){
    App.Person.createRecord({   
          fname: this.get('firstName'),
          lname: this.get('lastName'),
          contactype: 1
        });
        this.get('store').commit(); 
},

Basically this line is what changed: 基本上,这一行发生了变化:

this.get('store').deleteRecord(App.Person.find(1));

You where calling deleteRecord on a class definition App.Person which of course throws an error. 您在类定义App.Person上调用deleteRecord ,这当然会引发错误。

See working jsfiddle here. 请参阅此处的jsfiddle

Hope it helps. 希望能帮助到你。

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

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