Skip to content

Commit

Permalink
Fix Issue #11
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
apircher committed Feb 16, 2013
1 parent fbca551 commit 8029721
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions knockout.dirtyFlag.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -55,10 +54,9 @@
_lastCleanState(hashFunction(_objectToTrack));
_isInitiallyDirty(false);
};

return self;
};

return result;
};
})(ko);

0 comments on commit 8029721

Please sign in to comment.