I am trying to update the UI after chages to viewModel but it doesn\'t work , am I missing something ? http://jsfiddle.net/rdZjb/1/
viewModel = {
first
You are working with observables in wrong way. Each observable is a function so when you setting or geting value you should use ():
viewModel.firstName("Paul");
alert(viewModel.firstName());
Also it is bad practice to use jQuery click event. Use knockout click binding instead:
viewModel = {
firstName: ko.observable("adrian"),
OnClick: function() {
this.firstName("Paul");
alert(this.firstName());
}
};
Here is working fiddle: http://jsfiddle.net/vyshniakov/rdZjb/2/