Dirty Forms 2.0 BETA is Here!
What's New
- Advanced state management - if a user undoes their edits to a form, it is considered clean.
- New
dirty.dirtyforms
andclean.dirtyforms
events to enable/disable the submit button when the form is dirty or clean. - The default dialog has been changed to be the browser dialog, not Facebox. The default dialog configuration was so confusing it caused some people to write their own plugin (hope it was worth it!).
- Simpler dialog configuration - just implementing the
dialog.open
method is all that is required and events can be bound using a jQuery selector. - New pre-fabricated dialog packages for BlockUI, Bootstrap Modal, Facebox, jQuery UI, and PNotify (complete with legacy support for Dirty Forms version < 2.0).
- More consistent (and shorter) method and event names.
- Customizable event binding (useful for working with IFrames).
- Better documentation and examples.
Breaking Changes
If upgrading from previous versions of Dirty Forms, there are several breaking changes to be mindful of.
$.DirtyForms.onFormCheck()
has been removed. Use thedirty.dirtyforms
andclean.dirtyforms
events for similar functionality.- Facebox is no longer the default dialog. But if you need it, you can install the Facebox dialog module (a separate plugin).
- Support for the deprecated
helper.isNodeDirty()
has been removed. - Support for the deprecated
.setDirty()
,.isDirty()
, and.cleanDirty()
jQuery methods has been removed. - Automatic binding for top IFrames has been removed. This covered only 1 use case of many desired ways to configure IFrame support including event binding and target IFrame for refiring the event. You can now customize the event binding to get the desired result.
- Support for the deprecated
$.DirtyForms.disable()
function has been removed. Use$('html').addClass($.DirtyForms.ignoreClass)
instead. - The state behavior has been changed to store the initial state of each form input and to use this value to determine whether the input is dirty or clean. Editing an input back to its original state will automatically revert back to a clean state.
- The
.dirtyForms('setDirty')
method has been removed. This method doesn't fit with the new state management model. Use thehelper.isDirty()
method to provide dirty/clean status to Dirty Forms instead. - The default setting for
$.DirtyForms.ignoreClass
has been changed fromignoredirty
todirtyignore
for consistency with the other classes. - The
$.DirtyForms.isDirty()
method has been removed. Use$('selector').dirtyForms('isDirty')
instead. - The
beforeRefire.dirtyforms
event has been removed (duplicate functionality). Use theproceed.dirtyforms
event instead. - The
choicecommit.dirtyforms
andchoicecommitAfter.dirtyforms
events have been removed. You can get similar behavior ofchoicecommit.dirtyforms
by binding both theproceed.dirtyforms
andstay.dirtyforms
events. Also, you can get the same behavior ofchoiceCommitAfter.dirtyforms
event by binding to theafterstay.dirtyforms
event. - The
decidingcontinued.dirtyforms
event has been renamed toproceed.dirtyforms
. - The
decidingcancelled.dirtyforms
event has been renamed tostay.dirtyforms
. - The
decidingcancelledAfter.dirtyforms
event has been renamed toafterstay.dirtyforms
. - The
$.DirtyForms.title
property has been moved to be an optional part of each dialog module rather than a part of the core module. It can be set at$.DirtyForms.dialog.title = 'The title'
or.dirtyForms({ dialog: { title: 'The title' } })
. - The public method
$.DirtyForms.isDeciding()
has been removed. It is now safe to callchoice.commit(event)
(within thedialog.open()
method) multiple times, so accessing it publicly is no longer necessary. - The public method
$.DirtyForms.decidingContinue()
has been removed. You can either use thechoice.proceedSelector
to bind click events automatically, or setchoice.proceed = true
followed by a call tochoice.commit(event)
within thedialog.open()
method. - The public method
$.DirtyForms.decidingCancel()
has been removed. You can either use thechoice.staySelector
to bind click events automatically, or callchoice.commit(event)
(withchoice.proceed
set to the default offalse
). - The public method
$.DirtyForms.choiceCommit()
and$.DirtyForms.choiceContinue
property have been removed. Usechoice.commit(event)
andchoice.proceed
within thedialog.open()
method instead. - The
dialog.fire(message, title)
method has been renamed and signature changed todialog.open(choice, message, ignoreClass)
. Now it is possible to use custom dialogs without any calls to the public$.DirtyForms
object. - Support for
dialog.bind()
has been removed. Bind dialog events in thedialog.open()
method after the dialog has been added to the DOM instead. Note that you can now optionally use jQuery selectors for binding click events. - The
dialog.refire(content, event)
method has been renamed and signature changed todialog.unstash(stash, event)
. The stash is now a user-defined variable that can be any JavaScript type including jQuery object or JavaScript object. - The
dialog.selector
property has been renamed todialog.stashSelector
to indicate that it is related to stashing. This should still be the selector of a form or parent container of a form that is hosted inside of another dialog.