title: KnockoutJS date binding issue, using jQuery datepicker
body: <p>I am having a problem with binding a date to the object on my viewmodel. I have a date that I am getting from the server.</p>
  
  <pre><code> var viewModel = {
      profile : ko.mapping.fromJS(initialData),
  </code></pre>
  
  <p>I am binding the property to a text box. </p>
  
  <pre><code>&lt;input data-bind="datepicker: profile.Birthdate()" /&gt;
  </code></pre>
  
  <p>I am using the custom binding that I found on this here: <a href="http://jsfiddle.net/rniemeyer/NAgNV/" rel="nofollow">http://jsfiddle.net/rniemeyer/NAgNV/</a></p>
  
  <pre><code>    ko.bindingHandlers.datepicker = { 
  init: function(element, valueAccessor, allBindingsAccessor) { 
      //initialize datepicker with some optional options 
      var options = allBindingsAccessor().datepickerOptions || {}; 
      $(element).datepicker(options); 
  
      //handle the field changing 
      ko.utils.registerEventHandler(element, "change", function () { 
          var observable = valueAccessor(); 
          ko.observable($(element).datepicker("getDate")); 
          $(element).blur();
      }); 
  
      //handle disposal (if KO removes by the template binding) 
      ko.utils.domNodeDisposal.addDisposeCallback(element, function() { 
          $(element).datepicker("destroy"); 
      }); 
  
  }, 
  update: function(element, valueAccessor) { 
      var value = ko.utils.unwrapObservable(valueAccessor()), 
          current = $(element).datepicker("getDate"); 
  
      if(value != null)
      {
          if(value.toString()[0] = "/")
              value = new Date(parseInt(value.toString().substr(6)));
      } 
  
      if (value - current !== 0) { 
          $(element).datepicker("setDate", value); 
      }
  } 
  </code></pre>
  
  <p>}; </p>
  
  <p>I added the <strong>if(value.toString()[0] = "/")</strong> for formatting of the date to display in the textbox.</p>
  
  <p>This seems to work well except when I try to save the object add send it back the the server. I added an alert to verify and before I send the object to the server there is no change in the date.</p>
  
  <pre><code> save : function(){
          alert(this.profile.Birthdate);
  </code></pre>
  
  <p>Any ideas on what I am doing wrong?</p>
  
  <p>Thank you for your time.</p>