add/delete items from Ember Data backed ArrayController

前端 未结 4 792
旧时难觅i
旧时难觅i 2021-01-18 01:59

I\'m using an ArrayController in my application that is fed from a Ember Data REST call via the application\'s Router:

postsController.connectOutlet(\'commen         


        
4条回答
  •  一个人的身影
    2021-01-18 02:34

    Just for the record: as of today (using Ember Data 1.0.0-beta), the library takes this situation into account. When a record in an array gets deleted, the array will be updated.

    If you try to delete an element on that array manually, for example by using .removeObject(object_you_just_deleted) on the model of the containing controller (which is an ArrayController, hence its model an array of records), you'll get an error like:

    "The result of a server query (on XXXXX - the model you try to update manually) is immutable".

    So there is no need anymore to code by hand the deletion of the record from the array to which it belonged. Which is great news because I felt like using ED and working it around all the time... :)

提交回复
热议问题