Reputation: 6752
Why isn't this code not changing after 3 seconds? What am I doing wrong?
<div data-bind="visible: isBusy()">
is busy
</div>
<div data-bind="visible: !isBusy()">
is not busy
</div>
var viewModel;
function AppViewModel() {
var self = this;
self.isBusy = ko.observable(true);
}
function isNotBusyAnymore() {
viewModel.isBusy = ko.observable(true);
}
viewModel = new AppViewModel();
ko.applyBindings(viewModel);
setTimeout(isNotBusyAnymore, 3000);
Upvotes: 1
Views: 1239
Reputation: 44316
Because you keep making a new observable....and also your function always sets it to "true"
function isNotBusyAnymore() {
viewModel.isBusy(false);
}
Upvotes: 3