Appropriate use-case of bindings?

Given a generic enyo.Model, I want a view-component to edit the values of said models attributes. (This seems to be such a common pattern, I believe it should be built-into the framework.)
  1. Is is wise to use a 2-way binding from the enyo.Model.attribute_of_choice to the onyx.Input.attribute_field.value? e.g. from: ".person.firstName", to: ".$.person.firstNameField.value" (or should it be the other way around?)
  2. Is there a better way to accomplish the same things as the proposed binding in question #1?
  3. Is it possible / wise to build the bindings during runtime based on the model attributes? e.g. in create() or some such?

Comments

  • edited April 2014
    You can use the oneWay:false attribute in the binding declaration to make it a two-way binding and keep the values in sync with each other, which there shouldn't be any problems with, i.e.
    {from: ".person.firstName", to: ".$.person.firstNameField.value", oneWay: false}

    Check out the Binding API for programmatically creating your bindings: Binding Support
Sign In or Register to comment.