How to transform a regular JavaScript object to ObservableObject?

2 posts, 0 answers
  1. fbaptiste
    fbaptiste avatar
    19 posts
    Member since:
    Apr 2007

    Posted 12 Nov 2014 Link to this post

    The kendo documentation specifies two ways to create an observable object: 

    var viewModel1 = new {
      field1: "value1",
      field2: "value2"
    var viewModel2 = kendo.observable( {
      field1: "value1",
      field2: "value2"

    but what should be used when a regular javascript object already exists, and needs to become observable?
    for example, a DTO object that is being returned by a web service or one that is already created as follows:

    var viewModel = {
        name: "John Doe"
  2. Petyo
    Petyo avatar
    2444 posts

    Posted 13 Nov 2014 Link to this post

    Hi Fred,

    Something like this should work - 
    var viewModel = { name: "John Doe" };
    viewModel = kendo.observable(viewModel);

    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top