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.dirtyformsandclean.dirtyformsevents 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.openmethod 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.dirtyformsandclean.dirtyformsevents 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.ignoreClasshas been changed fromignoredirtytodirtyignorefor consistency with the other classes. - The
$.DirtyForms.isDirty()method has been removed. Use$('selector').dirtyForms('isDirty')instead. - The
beforeRefire.dirtyformsevent has been removed (duplicate functionality). Use theproceed.dirtyformsevent instead. - The
choicecommit.dirtyformsandchoicecommitAfter.dirtyformsevents have been removed. You can get similar behavior ofchoicecommit.dirtyformsby binding both theproceed.dirtyformsandstay.dirtyformsevents. Also, you can get the same behavior ofchoiceCommitAfter.dirtyformsevent by binding to theafterstay.dirtyformsevent. - The
decidingcontinued.dirtyformsevent has been renamed toproceed.dirtyforms. - The
decidingcancelled.dirtyformsevent has been renamed tostay.dirtyforms. - The
decidingcancelledAfter.dirtyformsevent has been renamed toafterstay.dirtyforms. - The
$.DirtyForms.titleproperty 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.proceedSelectorto bind click events automatically, or setchoice.proceed = truefollowed by a call tochoice.commit(event)within thedialog.open()method. - The public method
$.DirtyForms.decidingCancel()has been removed. You can either use thechoice.staySelectorto bind click events automatically, or callchoice.commit(event)(withchoice.proceedset to the default offalse). - The public method
$.DirtyForms.choiceCommit()and$.DirtyForms.choiceContinueproperty have been removed. Usechoice.commit(event)andchoice.proceedwithin 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$.DirtyFormsobject. - 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.selectorproperty has been renamed todialog.stashSelectorto 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.