Created
November 27, 2014 09:08
-
-
Save csainty/a8523753c38d48abaa23 to your computer and use it in GitHub Desktop.
Quick patch for KnockoutJS to handle date equality checks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function wrapEqualityComparerWithDateSupport(origFn) { | |
return function (a, b) { | |
return origFn(a, b) || | |
(a instanceof Date && b instanceof Date && a.getTime() === b.getTime()); | |
} | |
} | |
ko.observable.fn.equalityComparer = wrapEqualityComparerWithDateSupport(ko.observable.fn.equalityComparer); | |
ko.dependentObservable.fn.equalityComparer = wrapEqualityComparerWithDateSupport(ko.dependentObservable.fn.equalityComparer); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment