I have a javascript array in this format:
omega.franchiseInfo.rawdata = [{ Id: "Main", Title: "Main", Type: "main", items: [{ Id: "Menu1", Title: "Menu1", Type: "menu", items: [{ Id: "Menu1", Title: "Menu1", Type: "menu", items: [] }] }] }];
Each element has property elements, which are an array containing other elements. The number of array elements is not specified.
I use a knockout mapping plugin in an array to make it an observable array. And all elements of the array also become observable.
omega.franchiseInfo.observableRawData = ko.mapping.fromJS(language.rawdata);
What I want to accomplish then expands omega.franchiseInfo.observableRawData to become in its original pure javascript format. This means that it is equal to omega.franchiseInfo.rawdata . I know there are knockout methods like ko.utils.unwrapObservable , but javascript is not my forte, and I could not get this to work for my case. I also think that the function that will perform the task must be recursive in order to go through all the elements in the array.
Here is my fiddle:
http://jsfiddle.net/KHFn8/931/
I will be very pleased if someone can help me with this and provide working code. Thanks for your time and effort.
source share