Advertisement
Guest User

Untitled

a guest
Mar 5th, 2015
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. ko.mapping.fromJS(newData, mapping, modelToUpdate)
  2.  
  3.  
  4. var mapping = {}; //define your mapping (see documentation or blog post)
  5.  
  6. function ViewModel(){
  7. var self = this;
  8.  
  9. self.model = ko.mapping.fromJS({}, mapping);
  10. self.hub = $.connection.myHub();
  11. self.hub.client.updateModel = function(data){
  12. ko.mapping.fromJS(data, mapping, self.model);
  13. };
  14. self.hub.start().done(function(){
  15. //you could either make a call or have the "OnConnected" method trigger an 'updateModel'
  16. });
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement