Open pavel123123 opened 10 years ago
I guess, you want to use valueProp
and labelProp
and set them to id
and name
in your markup (see README).
I'm having the same issue, although I defined valueProp, labelProp and inputProp.
Having this category object: {"id": "Computers", "path": "/Computers", "name": "Computers"}
if in the view model I call self.category(cat); // cat being the object above
the autocomplete displays "/Computers" instead of "Computers".
this is the code of the update method in the autocomplete:
this.update = function(element, valueAccessor) { var options = unwrap(valueAccessor()), value = unwrap(options && options.value); element.value = value; };
I debugged this in firefox, and options.value = "/Computers"
Note that if the value is selected in the autocomplete, everything works ok. the problem is when the value is updated from the model
I had this problem when the source was an observable array, it was somehow backpopulating the array with nothing.
Using ko.toJS(vm) as the source fixed the issue however.
I have binding on object {id:1,name:"some text"} When I write in viewModele the code this.objectValue = ko.observable(1); I see in textBox "1" instead "some text"
Can I set this.objectValue any value from ViewModel?
Thank you!