There are several similar ways to handle this. The basic idea is that you need to create a writable computable observable in order to bind a checkbox.
You can do this directly in your model, using the expander or adding a function to the observed base (ko.observable.fn).
However, since you are using the mapping plugin and probably do not want to customize the way you create your objects or add additional properties, I think using custom bindings is the best option. Your model really does not have to care about maintaining the opposite of your property, so we can actually complete this part when binding.
Here is an inverseChecked binding that inserts a recordable calculated observable between your real observable and the binding. Then he simply uses real test binding to do his job.
ko.bindingHandlers.inverseChecked = { init: function(element, valueAccessor, allBindingsAccessor) { var value = valueAccessor(); var interceptor = ko.computed({ read: function() { return !value(); }, write: function(newValue) { value(!newValue); }, disposeWhenNodeIsRemoved: element }); var newValueAccessor = function() { return interceptor; };
Here is an example: http://jsfiddle.net/rniemeyer/Kz4Tf/
For your binding visible you can make visible: !needsReview()
source share