I was trying to make a knockout mapped JSON schema editor in table format. I successfully mapped json object, but issue is when i'm dealing with json array.
Code
var l_Model;
//Create model
l_Model = function(l_data) {
var self = this;
//map data from json as observables
ko.mapping.fromJS(l_data, {}, self);
//observable to get equation from json
self.Eqn = ko.observable(null);
};
//view model mapping to html
var viewModelMapping = {
'dataModel': {
create: function(options) {
return new l_Model(options.data);
}
}
};
var vm = ko.mapping.fromJS(Data);
This code works as long as data is
data = {}
But When I deal with array of json objects I'm not able to map it
data =[{},{},{},.....]
I'm getting error in the console
Uncaught ReferenceError: Unable to parse bindings.
l_row += "<td class='seRow'><span data-bind='text: $root[" + index + "]." + key + "'/><textarea rows='1' data-bind='value: $root[" + index + "]." + key + "' /></td>";The first row will display the right values