0.8.4 • Published 2 years ago

jquery.dirty v0.8.4

Weekly downloads
129
License
MIT
Repository
github
Last release
2 years ago

jquery.dirty

A jQuery plugin to determine when a form has been modified (dirtied) and act accordingly

All state information about the form is held in the data object for the form rather than adding data- attributes to the DOM

Gitter

https://gitter.im/jquerydirty/Lobby

Usage

$("#myForm").dirty();

Options

  • preventLeaving - boolean indicating whether on not to show a warning if the user attempts to navigate away from the form with pending changes

    • Default: false
  • leavingMessage - message to display when preventLeaving is true

    • Default: 'There are unsaved changes on this page which will be discarded if you continue.'
  • onDirty - function called when form is modified

  • onClean - function called when form is restored to original state

Methods

$("#myForm").dirty("isDirty"); returns true if a form has been modified

$("#myForm").dirty("isClean"); returns true if a form has not been modified

$("#myForm").dirty("refreshEvents"); remove and reapply events. Can be used if content is dynamically added to form

$("#myForm").dirty("resetForm"); reset the form to the original state when $("#myForm").dirty(); was called

$("#myForm").dirty("setAsClean"); set the current state of the form as the 'clean' state. Calling resetForm after this will restore the form to the state when setAsCleanwas called

$("#myForm").dirty("setAsDirty"); set the current state of the form as the 'dirty' state

$("#myForm").dirty("showDirtyFields"); returns jQuery array of all modified fields in the form

Credits

Thanks to Tomasz Świenty for feedback and a fix for an issue where a value could resolve as null

0.8.4

2 years ago

0.8.3

3 years ago

0.8.2

3 years ago

0.8.1

4 years ago

0.8.0

4 years ago

0.7.3

4 years ago

0.7.2

6 years ago

0.7.1

6 years ago

0.7.0

6 years ago

0.5.0

7 years ago

0.4.0

7 years ago

0.3.0

8 years ago