Skip to content

Instantly share code, notes, and snippets.

@collectiveidea
Created March 25, 2010 02:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save collectiveidea/343081 to your computer and use it in GitHub Desktop.
Save collectiveidea/343081 to your computer and use it in GitHub Desktop.
$('input, textarea').live('keyup click change', function() {
if(this.defaultValue != this.value) {
$(this.form).trigger('changed');
}
});
$('form').live('changed', function() {
$(this).data('dirty', true);
}).live('submit', function() {
var wasDirty = $(this).data('dirty');
$(this).data('dirty', false);
return !wasDirty;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment