jquery.AreYouSure icon indicating copy to clipboard operation
jquery.AreYouSure copied to clipboard

Fix rescan bug and implement getDirtyFields

Open AlejandroFrias opened this issue 8 years ago • 1 comments
trafficstars

@codedance

Changes

  1. Fixing small bug in resan.
  2. Exposing getDirtyFields and isDirtyField as available triggers

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:

$("#my-form").trigger("getDirtyFIelds.areYouSure").data("dirtyFields");

Just adds a data value dirtyFIelds in which the array of dirty fields is added.

AlejandroFrias avatar Aug 24 '17 22:08 AlejandroFrias

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

DIntriglia avatar Dec 28 '20 18:12 DIntriglia