Skip to content

Instantly share code, notes, and snippets.

@beyond-code-github
Last active August 29, 2015 13:55
Show Gist options
  • Save beyond-code-github/8735766 to your computer and use it in GitHub Desktop.
Save beyond-code-github/8735766 to your computer and use it in GitHub Desktop.
Skeleton change tracked array extender for knockout.kj
ko.extenders.trackArrayChange = function (target, track) {
if (track) {
target.isDirty = ko.observable(false);
target.added = ko.observableArray([]);
target.removed = ko.observableArray([]);
var addItem = function (item) {
//...
};
var removeItem = function (item) {
//...
};
target.getChanges = function () {
var result = {
added: target.added,
removed: target.removed
};
return result;
};
//....
//....
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment