arturadib / agility

Javascript MVC for the "write less, do more" programmer
http://agilityjs.com
MIT License
542 stars 70 forks source link

Data binding default model values on first initialization #110

Closed garygreen closed 7 years ago

garygreen commented 10 years ago

When using simple data binding on i.e a select element, when a model is created it will not upon creating automatically set the values as on the select elements. This should be the desired effect as on first initialization the model is out of sync with what value is actually on the element. In my opinion, it should upon being created transverse through the model bindings and set the values as on the elements, however if values are supplied when creating the agility object are supplied it use those values instead and 'sync' with the bound elements.

Is there any decent way around this, aside from creating the model object with default values which can be cumbersome and add unnecessary code?

phonovision commented 10 years ago

If the bound variable is null previous to adding the options, is seems to work as you intend.