Skip to content

Conversation

@AlejandroFrias
Copy link

@AlejandroFrias AlejandroFrias commented Aug 24, 2017

@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 #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 AlejandroFrias changed the title Fix rescan overriding blank values Fix rescan bug and implement getDirtyFields Aug 24, 2017
@AlejandroFrias AlejandroFrias changed the title Fix rescan bug and implement getDirtyFields WIP Fix rescan bug and implement getDirtyFields Aug 24, 2017
@AlejandroFrias AlejandroFrias changed the title WIP Fix rescan bug and implement getDirtyFields Fix rescan bug and implement getDirtyFields Aug 24, 2017
@DIntriglia
Copy link

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

Copy link

@DIntriglia DIntriglia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything looks good to merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants