Two Way Data Binding with Collection View and Array


#1

Sorry if this is the wrong place for this, however I’m struggling, and I think it’s a fundamental lack of understanding on my part on how to make this happen.

Basically I’ve gone through the docs and implemented what I think is the best way to display array data via a CollectionView, which uses a template View to display individual inputs that should allow you to edit the array elements. Somewhere along the way the binding link is broken, and my arrays are not being updated in the Data Store.

I’m pretty sure this is happening in the redirection of data through the view types, or it has something to do with the custom DataStore transforms I’ve used to map the JSON Arrays to the Data Store and back.

Anyway I’ve posted on Stack Overflow as well, with a bit more detail here : http://stackoverflow.com/questions/22472266/why-is-my-ember-data-store-not-updating-correctly-with-array-controller-and-coll

And the JSFiddle example can be found here : http://jsfiddle.net/Murcho/SwP4r/

I’m pretty new to Ember, and I’m really enjoying using it, but this has had me stumped for days now! Any help or guidance would be greatly appreciated.


#2

Just in case someone comes across the issue, I have managed to fix this.

The problem was the array of information I was indexing was an array of strings, which ember seems to not be able to track on it’s own :

App.UserSetting.FIXTURES = [
    { id: 1, emergencyPhones: ["12345678", "5555555", "123123123"] }
];

By wrapping each of the strings in an object, Ember was able to correctly propagate the information back to the data store :

App.UserSetting.FIXTURES = [
    { id: 1, emergencyPhones: [{string: "12345678"}, {string: "5555555"}, {string: "123123123"}] }
];