error with setObject when the first property has the same value than before

If I use setObject with two value and the first value is the same than the one currently in the model, the bindings are not correctly updated.

see http://jsfiddle.net/Bcn3k/9/

Comments

  • I haven't used the View and Controller portions of 2.3 so I'm not sure what the purpose of ModelController is here.

    This is how I've been doing bindings:

    http://jsfiddle.net/ryanjduffy/Bcn3k/10/

    In your example, swapping out the reference from the ModelController to the Model works:

    http://jsfiddle.net/ryanjduffy/Bcn3k/11/
  • ModelController is designed to stand in for a model object when the state is indeterminate. For example, you've got a model that's being loaded via a web service, but isn't available when your view that binds to it is created.
  • @theryanjduffy thanks for your example. This looks like a bug with the ModelController
  • edited November 2013
    BTW, @yeye77, thanks for the test case. It shows a problem with the handling of the _updated flag in setObject where only the last property to be processed counts in triggering a change event. We should be able to fix that pretty quickly.

    (Bug logged as https://enyojs.atlassian.net/browse/ENYO-3538)

    Update: a fix is now pending review.
  • @unwiredben I updated my project with the latest enyo from github and everything works as expected now. Thanks!
    Regarding ModelController, I'm still not sure to get the difference between binding to a ModelContoller or binding to an object that will be set at runtime (i.e when you get your model from your webservivce you do myView.setModel(modelfetchedfromwebservice)
  • Yeah, I'm not too sure about ModelController's usefulness either. I thought it provided some additional protection, but changing models that are bound to properties seems to work fine. Perhaps it comes into its own if you derive new controllers from it or if you're directly calling into a model instead of just using a binding.
Sign In or Register to comment.