I have got a subscribe function on one of my observable objects. I assume that the subscribe function should only execute when there is a change to it's observable object. Though when I trace my code, I can see that it's being executed after I call the ko.applyBindings(MyViewModel); at initialization.
Here is what I have got in my viewmodel:
function MyViewModel(myModel){
this.myProperty = ko.observable(myModel.myProperty);
this.myProperty .subscribe(function (val) {
// do sth..
}, this);
}
and this is where I make the call to applyBindings:
jQuery(document).ready(
function ($) {
ko.applyBindings(MyViewModel);
});
Is this an expected behavior?
The subscribe function is being called right after ko.applyBindings(MyViewModel);, meaning that I don't get any input from the UI in the meanwhile.
I would want to have it so it only executes my subscribe function body whenever the value of myProperty is changed. Is there a way for me to track my observable object to see where is the change happening?
selectusing thevaluebinding and have an initial numeric value that is getting updated to be a string? - RP Niemeyer