Ember TextField valueBinding with dynamic property

前端 未结 3 1486
独厮守ぢ
独厮守ぢ 2020-12-09 23:34

I\'m trying to write a generic view that handles custom fields in my app, but I\'m having a hard time getting this to work. Here\'s the scenario - I have a fieldDef

3条回答
  •  难免孤独
    2020-12-09 23:54

    @ahmacleod great answer man. Just in case anyone is interested it works great extending select too:

    import Ember from 'ember';
    
    export default Ember.Select.extend({
      fieldId: null,
      values: null,
    
      valueChange: function() {
        var fieldId = this.get('fieldId');
        var values = this.get('values');
        if (values && fieldId) values[fieldId] = this.get('value');
      }.observes('value')
    });
    

    Call it as an normal component (components/dynamic-select.js)

    {{#each id in fieldIds}}
       {{dynamic-select content=fieldIds fieldIdBinding="header"       
         valuesBinding="fields"}}
    {{/each}}
    

提交回复
热议问题