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 = {
firstName : ko.observable("adrian")
}
$("#button1").click(
function ()
{
viewModel.firstName = "Paul";
alert(viewModel.firstName);
}
)
ko.applyBindings(viewModel);
You are working with
observablesin wrong way. Eachobservableis a function so when you setting or geting value you should use():Also it is bad practice to use jQuery click event. Use knockout
clickbinding instead:Here is working fiddle: http://jsfiddle.net/vyshniakov/rdZjb/2/