Created
November 7, 2011 17:07
-
-
Save chrisdew/1345534 to your computer and use it in GitHub Desktop.
flashOnChange
This file contains 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
var flashTime = new Date(); | |
ko.bindingHandlers.flashOnChange = { | |
update: function (element, valueAccessor) { | |
// If the page has just loaded, don't flash all the data. | |
if (new Date().getTime() < flashTime.getTime() + 1000) return; | |
// Whenever the value subsequently changes, flash it | |
var value = valueAccessor(); | |
$(element).addClass('new'); | |
setTimeout(function() { $(element).removeClass('new'); }, 2000); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment