I have a component that accepts an array of values and array of the same length with a validation error string for each value. I'd like to display a list of form fields with inputs for each value and error pair. I've tried creating a computed property like this:
var myComponent = Ember.Component.extend({
//values: <provided array of input values>
//errors: <provided array of error strings>
valuesAndErrors: function() {
var combined = [];
for (var i = 0; i < values.length; i++) {
combined.pushObject({
value: this.get('values')[i],
error: this.get('errors')[i]
});
}
return combined;
}.property('values.@each', 'errors.@each')
});
But unfortunately the changes made to values in valuesAndErrors
(e.g. via {{input value=valuesAndErrors.value}}
) are not pushed back to the source values
array. What is the correct way to iterate over the values
and errors
arrays simultaneously without breaking bindings like this?
I'm currently using Ember 1.9.