title: Externally update knockout JS viewmodel
body: <p>In Brief : I need to replace an <strong>entire object</strong> inside my viewmodel which is created through the knockout mapping plugin. How do I do this? This should in-turn update the controls bound to that <strong>object</strong>...</p>
  
  <p>More details :</p>
  
  <p>I am using knockout with signalR.</p>
  
  <p>I'm able to retrieve the JSON from the server during page load,parse it using ko.mapping.FromJSON or FromJS after using ParseJSON and it loads it into the viewmodel during the first time.</p>
  
  <p>But, after that, I am unable to update the viewmodel from the server using SignalR.</p>
  
  <p>Here's my viewmodel :</p>
  
  <pre><code>  function viewmodel(objServerModel) {
          var self = this;
          self.profile = objServerModel;
          self.devices = ko.observableArray(['one', 'two']);
          self.updateprofile = ko.observable('@Html.Raw(HttpUtility.JavaScriptStringEncode(Test.ReadXmlIntoModel()))')
  
  
      }
  </code></pre>
  
  <p>Here's the code I am using to update the model during run time..the following function is called from the server...</p>
  
  <pre><code>function UpdateVM(modeljson)
  {
  
      var objResult = $.parseJSON(modeljson);
      var objModelFromServer = ko.mapping.fromJS(objResult, {},objModel.profile);
      // var objFinal = objResult.capture.capturevideo.videodevice.Value;
  // objModel =  viewmodel(objModelFromServer);
    //  objModel.profile(objModelFromServer);
  
      viewmodel(objModelFromServer);
      return objModel;
  }
  </code></pre>
  
  <p>This textbox should get updated during run time when UpdateVM is called :</p>
  
  <pre><code>&lt;input id="txt1" data-bind="value: profile.capture.capturevideo.videodevice.Value" type="text" /&gt;
  </code></pre>
  
  <p>Please help...</p>
  
  <p>Thanks.</p>
  
  <p><strong>Edit : Please note that it's not a string. It's an object created using knockout's mapping plugin.I need to replace the existing object with another object of the same structure with different values created by the mapping plugin</strong></p>