I am currently working on updating a JSON object in memory using the knockout.js user interface. However, I have encountered an issue where changes made in the UI do not seem to reflect on the JSON data itself. To troubleshoot this problem, I have added buttons with console.log(config) for testing purposes. Any suggestions or insights on how to resolve this would be highly appreciated. Thank you!
edit.js
var config = {
"departments": [
{
"name": "Step Down"
}, {
"name": "ER"
}]
};
var DepartmentViewModel = function (dep) {
var self = this;
self.name = ko.observable(dep.name);
}
function ConfigViewModel() {
var self = this;
self.departments = ko.observableArray([]);
ko.utils.arrayForEach(config.departments, function (dep) {
self.departments.push(new DepartmentViewModel(dep));
});
}
ko.applyBindings(new ConfigViewModel());