coderenaissance / knockout.viewmodel

The knockout viewmodel plugin is the fastest, smallest, cleanest, most flexible way to create a knockout viewmodel.
http://coderenaissance.github.com/knockout.viewmodel
106 stars 28 forks source link

Internal objects not being made observable #46

Open sgiurgiu opened 11 years ago

sgiurgiu commented 11 years ago

Hi, I have been struggling with this issue for the last 24 hours or so and I am not sure what am I doing wrong. JSFiddle sample: http://jsfiddle.net/u9Qu3/6/

The problem: As it can be seen , the original data contains object "something" with certain values (B and B1). In the extend I set on the {root} the available things observable Array. I bind then that observable array onto a select element. But initially the select element has the "Choose..." item selected by default, not the one that comes from the data.

As the code is right now on fiddle, changing manually the selection of the dropdown doesn't affect the value of "something". If I uncomment the "root.something = ko.observable(root.something);", the initial value is still null ("Choose...") but when manually changing the selection , the value of "something" gets updated accordingly. How can I make this work as desired? That is ... upon loading the selected item in the drop down should be whatever comes from the server,and if manually changing it, it should change in the data?

What am I doing wrong?

Thank you.