From 80297217290b12e55be4c09ed4c96f6a1f2b5bfb Mon Sep 17 00:00:00 2001 From: Andreas Pircher Date: Sat, 16 Feb 2013 16:19:15 +0100 Subject: [PATCH] Fix Issue #11 Problem: isDirty and reset functions where added to the model. Fixed it by moving the self-assignemnt out of the result function. So the this-Reference of the actual dirtyFlag-Object is saved in the variable self and when the result function is called later, the isDirty and reset functions are added to the dirtyFlag-Object. --- knockout.dirtyFlag.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/knockout.dirtyFlag.js b/knockout.dirtyFlag.js index f979447..45f4b9e 100644 --- a/knockout.dirtyFlag.js +++ b/knockout.dirtyFlag.js @@ -35,13 +35,12 @@ hashFunction = hashFunction || ko.toJSON; var + self = this, _objectToTrack = objectToTrack, _lastCleanState = ko.observable(hashFunction(_objectToTrack)), _isInitiallyDirty = ko.observable(isInitiallyDirty), result = function () { - var self = this; - self.forceDirty = function () { _isInitiallyDirty(true); @@ -55,10 +54,9 @@ _lastCleanState(hashFunction(_objectToTrack)); _isInitiallyDirty(false); }; - return self; }; - + return result; }; })(ko);