title: Why is checkbox in knockoutJs written to only when checked?
body: <p>I'm using a special extended version of Ko which uses a commit()/peek() type functions on a dependant observable so that I only save the data onto the form if it is committed to the database (on Ok) and reverted on cancel.</p>
  
  <p>Problem I'm having is that when I check a checkbox, the write function is called correctly on the protected observable. However, if I uncheck the checkbox, the write function isn't called, so when the model is sent to my MVC controller, the checkbox boolean is still TRUE.</p>
  
  <p>Why is knockout not writing the FALSE value?</p>
  
  <p><strong>UPDATED QUESTION WITH CODE:</strong></p>
  
  <p>Please see this JsFiddle here to demonstrate: <a href="http://jsfiddle.net/b2Qu2/3/" rel="nofollow">http://jsfiddle.net/b2Qu2/3/</a></p>
  
  <p><em><strong>Minor issue</em></strong></p>
  
  <p>Note that there is 1 other problem with the demo - for some reason, when I check/uncheck the checkbox, the peeked value is not updated on the UI even though it is chained to a dependentObservable.  You can still peek the value by clicking the 'peek' button.</p>
  
  <p><em><strong>Major Issue</em></strong></p>
  
  <p>To reproduce problem:</p>
  
  <pre><code>1) Click 'peek' button: Shows FALSE - CORRECT
  
  2) Check IsAdmin checkbox
  
  3) Click 'peek' again: Shows TRUE - CORRECT
  
  4) Uncheck IsAdmin
  
  5) Click 'peek' again: SHOWS TRUE - INCORRECT!!
  </code></pre>
  
  <p><strong>Example scenario</strong></p>
  
  <p>Imagine a dialog is shown with a checkbox for an Admin user. Only 1 admin user can be set, and the server responds with valid/invalid if an admin user already exists.
  The user then unchecks the checkbox, but now the viewmodel thinks the checkbox is ALWAYS true?? Reason for using the protectedObservable is if the server response succeeds, the commit() method is called so everything is persisted on the UI. If the user cancels the dialog or an error occurs, the original values are not overwritten.</p>