knockout js get old and new value
ko.subscribable.fn.subscribeChanged = function (callback) {
var savedValue = this.peek();
return this.subscribe(function (latestValue) {
var oldValue = savedValue;
savedValue = latestValue;
callback(latestValue, oldValue);
});
};
//example use
function Mvvm() {
var self = this;
self.Input = ko.observable();
self.Input.subscribeChanged(function (newValue, oldValue) {
console.log("new value: " + newValue);
console.log("old value: " + oldValue);
});
}