mercredi 13 janvier 2016

Ember Two Way Binding

Using Ember 2.0. I have an object that I want to bind with a set of inputs. The keys in the object are not known until run time. Here is what I have:

JS

export default Ember.Component.extend({
  form: {},
  fields: Ember.computed(function() {
   //Dynamically gets list of fields as array
   return fields;
  })
});

HBS

{{#each fields as |field|}}
  {{field.title}} - {{input type="text" value=(mut (mergeHelper "form." field.title))}}
{{/each}}

MERGEHELPER

export function mergeHelper(params) {
  var result = "";
  for (var i = 0; i < params.length; i++) {
    result+=params[i];
  }
  return result;
}

The problem I have is when I go to edit the input I get the following error: "Uncaught Error: Stream error: setValue not implemented". What am I doing wrong? Thanks.




Aucun commentaire:

Enregistrer un commentaire