This is a migrated thread and some comments may be shown as answers.

Retrieving the original object from "observable" wrapper

2 Answers 84 Views
MVVM
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 1
Andrew asked on 25 Nov 2013, 11:51 PM
Considering the following data object:

var obj = {
person: {
name: "Holmes"
address: {
apt: 221B,
street: "Baker",
city: "London"
    }
  }
}

And the viewModel built from the above object to be used in a MVVM presentation:
var viewModel = kendo.observable(obj);
kendo.bind(..., viewModel)

After the changes have been done to the viewModel by UI,
I would like to extract the original object as a whole (rather then field by field)
with the changes incorporated in it.

The extracted object would be then sent to another part of the application for processing
and is expected to have no additional events/functions/types built into it.
In other words, I would like to detach the "observable" from the object.

How can I do that?
Thanks,
Andrew

2 Answers, 1 is accepted

Sort by
0
Accepted
Alexander Valchev
Telerik team
answered on 27 Nov 2013, 12:12 PM
Hello Andrew,

To do that you can use the toJSON method of the observable object.

Regards,
Alexander Valchev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Andrew
Top achievements
Rank 1
answered on 29 Nov 2013, 06:37 PM
Thanks.
Tags
MVVM
Asked by
Andrew
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Andrew
Top achievements
Rank 1
Share this question
or