Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Example usage of change tracking in a complex view model, including a primitive array
var viewModel = {
Name: ko.observable("Pete"),
Age: ko.observable(29),
Skills: ko.observableArray([
"TDD", "Knockout", "WebForms"
}),
Occupation: ko.observable("Developer")
};
applyChangeTracking(viewModel);
viewModel.Occupation("Blogger");
viewModel.Skills.push("Change tracking");
viewModel.Skills.remove("WebForms");
getChangesFromModel(viewModel);
/* -> {
"Skills": {
added: ["Change tracking"],
removed: ["WebForms"]
},
Occupation: "Blogger"
} */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.