Use of bindings

I'm attempting to bind a form-input-value with an instantiated-object value (upon component creation).
However, it seems the input-value is never set. Please advise: http://jsfiddle.net/d8zx5/

Comments

  • A couple of things:

    First, you need to be at enyo(nightly) because the data-binding features are not in 2.2.

    Next, you can't bind to embedded properties like that. They mostly need to be flat. They also need to be observable, so it's best to make a new enyo.Object (or a custom kind maybe based on enyo.Model) and set the properties thusly:

    this.blog = new enyo.Object({blog_id: 27});

    Now you can observe .blog.blog_id and bind it wherever.

    I've updated your fiddle with a working example for you to hack on:

    http://jsfiddle.net/d8zx5/1/
  • edited April 2014
    Couple notes:

    * You have to use the nightly build on jsFiddle for bindings rather than 2.2.0
    * Bindings expect an instance of enyo.Model and not just a simple object
    * You shouldn't access the internal $ has of another component (.$.inputs.$.blogBlogID.value)

    Refactored a bit to show my usual approach. Hopefully that helps.

    http://jsfiddle.net/wCJFz/

    ... Dave beat me to it ... +1 for him :)
Sign In or Register to comment.