簡體   English   中英

模型的刪除/更新記錄在余燼數據中不起作用?

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

在這里做了簡單的CRUD程序。

但是在單擊刪除時(這里我正在嘗試刪除模型的第一條記錄)它沒有刪除任何記錄,而是拋出錯誤

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

最近兩天有人可以幫助我解決這個問題嗎? 我已經在這里發布了我的代碼。

我已經編輯了小提琴以添加創建記錄的功能(在此),它正在表中添加空白記錄。 在這種情況下,誰能告訴我如何添加/創建記錄?

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

基本上,這一行發生了變化:

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

您在類定義App.Person上調用deleteRecord ,這當然會引發錯誤。

請參閱此處的jsfiddle

希望能幫助到你。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM