Open AlejandroFrias opened 7 years ago
I know this is an old item, but I have confirmed that this implementation works perfectly, and should be merged if possible. I also modified it a bit to add support for a input dirty field class, so I can easily style fields that are dirty and identify which fields are causing the form to be dirty right with jQuery. Thanks @AlejandroFrias
@codedance
Changes
Rescan Bug
Rescan shouldn't be recalculating the original value when the original value is actually an empty string.
My use case that came across this (IMO) bug: Dynamic form. Add a new blank field to be filled out. Run rescan, which correctly sets the original value of the field to empty string. Then fill in the field, yay it's dirty. Then I add another field. This time rescan incorrectly changes that first field's original value to what I've typed so. Oh no, form suddenly not dirty anymore.
Exposing
getDirtyFields
Also needed some functionality to keep my code cleaner. looks like this was asked for in issue https://github.com/codedance/jquery.AreYouSure/issues/74. So here's my take on that, too.
You can now get the dirty fields:
Just adds a data value
dirtyFIelds
in which the array of dirty fields is added.