One attribute of my payload is a plain array of strings. I did create a custom transform to properly transform it. It worked so far. The array is rendered in my template and I can iterate over it with the each helper. Unfortunately, the onChange action of the input field does not deliver the changed string. Furthermore, the changes made to the input field is overwritten by the initial value immediately. I did read through the ember docs dealing with ArrayProxy but quarrel with how to implement it (model, controller). Any suggestions?
model:
export default DS.Model.extend({
references: DS.attr('array'), ...
template:
{{#each model.references as |reference|}}
{{paper-input value=reference onChange=(action "updateReference" reference)}}
{{/each}}
transforms/array.js:
export default DS.Transform.extend({
deserialize: function(serialized) {
return (Ember.typeOf(serialized) == "array") ? serialized : []
},
serialize: function(deserialized) {
var type = Ember.typeOf(deserialized);
if (type == 'array') {
return deserialized;
} else if (type == 'string') {
return deserialized.split(',').map(function(item) {
return jQuery.trim(item);
});
} else {
return [];
}
}
});