I\'m having a problem with knockout \"checked\" binding. It seems that \"change\" event at checkbox return old value, before it is updated(so if it was unchecked it will return
Since you persisted on stating that the lack of ko.observables
is not an issue, I've looked at it closer. It seems, that you are correct! The change
event is fired before the actual value is set. I'm afraid I do not know the reason for this.
But there is an easy way to fix this: just change change
event to click
event:
Remember, that you have to explicitly put return true;
at the end of click
event handler. Otherwise the new value won't be set to checkbox.
If you do not want to use click
event, then you can do it the other way. Subscribe to changes of ShowOpened
:
this.ShowOpened = ko.observable(ShowOpened);
this.ShowOpened.subscribe(function(newValue) {
/* Do something when ShowOpened changes.
newValue variable holds the new value, obviously. :) */
});