title: knockout mapping JSON update existing view model
body: <p>I have this JSON data coming from the server:</p>
  
  <pre><code>{"HaveNotification":false,"IsError":false,"Title":null,"Description":null}
  </code></pre>
  
  <p>and am trying to populate this view model via ko.mapping:</p>
  
  <pre><code>var notifyVM = {
    HaveNotification: ko.observable(true),
    IsError: ko.observable(false), 
    Title: ko.observable('Title goes here'), 
    Description: ko.observable('Description goes here'), 
  }
  </code></pre>
  
  <p>with this code, which is called on a polling interval:</p>
  
  <pre><code>function pollNotifications() {
  
    $.getJSON('@Url.Action("GetNotifications", "Home")', function (data) {
  
      ko.mapping.fromJSON(data, notifyVM);
  
      setTimeout(pollNotifications, 10000);
    });
  }
  </code></pre>
  
  <p>and this is page load code:</p>
  
  <pre><code>$(function () {
  
    ko.applyBindings(notifyVM);
  
    setTimeout(pollNotifications, 10000);
  });
  </code></pre>
  
  <p>but its not working. If I inspect the view model after the fromJSON call the observables are not updated, they are still at their initial values.</p>
  
  <p>UPDATE:
  Some more info... if I do this in the pollNotifications function</p>
  
  <pre><code>var newVM = ko.mapping.fromJSON(data);
  </code></pre>
  
  <p>I notice that the view model it creates is not the same as my one, it consists of a single observable function, whereas mine is an object with a set of observable properties.</p>