Skip to content

Commit 2595cfa

Browse files
author
Marc Sutton
committed
Add support for form reset buttons
If the user clicks the form reset button then force the status of the form to be set to clean. The change event is called but we can't use that, or bind reset to checkForm, because the form values are not reset until after the change and reset events have triggered.
1 parent c0c3fc2 commit 2595cfa

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

jquery.are-you-sure.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,12 @@
8585
}
8686
});
8787
}
88-
var changed = isDirty != $form.hasClass(settings.dirtyClass);
8988

89+
markDirty($form, isDirty);
90+
};
91+
92+
var markDirty = function($form, isDirty) {
93+
var changed = isDirty != $form.hasClass(settings.dirtyClass);
9094
$form.toggleClass(settings.dirtyClass, isDirty);
9195

9296
// Fire change event if required
@@ -113,6 +117,7 @@
113117

114118
$(this).find(settings.fieldSelector).each(storeOrigValue);
115119
$(this).find(settings.fieldSelector).bind('change keyup', checkForm);
120+
$(this).bind('reset', function() { markDirty($(this), false); });
116121
});
117122
};
118123
})(jQuery);

0 commit comments

Comments
 (0)