Skip to content

Instantly share code, notes, and snippets.

@chrisdew
Created November 7, 2011 17:07
Show Gist options
  • Save chrisdew/1345534 to your computer and use it in GitHub Desktop.
Save chrisdew/1345534 to your computer and use it in GitHub Desktop.
flashOnChange
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