Releases: snikch/jquery.dirtyforms
2.0.0
Important - Breaking Changes from Version 1.x
Please review the breaking changes in 2.0.0-beta00003 and 2.0.0-beta00005. Although much of the API is similar, due to the new state management behavior changes of Dirty Forms, it is unlikely your current code will work as is. Please review the documentation and test thoroughly if upgrading from 1.x.
Change Log
- Added documentation about Setting a Form Dirty Manually, since this is a frequent question (#93, #89, #79).
2.0.0-beta00008
Change Log
- Enhancement: Added support for NPM to PNotify dialog module.
- Bug: Fixed PNotify dialog module so it is compatible with PNotify 3.x.
2.0.0-beta00006
Change Log
- Bug: Fixes #87, Typo in Bootstrap dialog module - "messsageClass" property should be "messageClass".
2.0.0-beta00005
Breaking Change - Anchor Tags without HREF no longer ignored by default
Ignoring anchor tags without HREF tags was a feature added before the release of 1.0.0. Before that, these anchors were not ignored. However, since it is much more difficult to attach events to anchors without HREF tags than it is to simply supply an ignoreSelector
or add the ignoreClass
to those elements you want to ignore (as per the following example), it is better to include them by default.
Attaching an Event Handler
$(document).bind('bind.dirtyforms', function (ev, events) {
var originalBind = events.bind;
events.bind = function (e) {
$('#myTab li a').on('click', events.onAnchorClick);
originalBind(e);
};
});
Ignoring Anchor Tags
$('form').dirtyForms({ ignoreSelector: 'a.some-class:not([href])' });
Re-Ignoring Anchors without HREF
If you have been working with a version of Dirty Forms 1.0.0 to 2.0.0-beta00004, you can get back the same behavior by adding the following ignoreSelector
on the first call to .dirtyForms
.
$('form').dirtyForms({ ignoreSelector: 'a:not([href]),a:not([href]) >' });
Alternatively, if .dirtyForms
has already been called:
$.DirtyForms.ignoreSelector = 'a:not([href]),a:not([href]) >';
Change Log
- Bug: Fixes #82, UMD header causes crash with RequireJS.
- Enhancement: In conjunction with the fix for #82, removed UMD support from all distribution sources except for NPM. This is the same thing that jQuery did, so we are following their lead.
- Bug: Fixes #84, Improved performance of
:dirty
selector (thanks @ziykon). - Bug: Fixed performance issue with CKEditor helper when there are no helpers in any of the forms on the page.
- Enhancement: Improved performance of
isDirty
method by looping through all selected elements and returning immediately when the first dirty field is found. This on average results in about a 10x increase in performance. - Enhancement: Reverted #59 in favor of #55 because some users complained about Dirty Forms not functioning with PJax and Bootstrap tabs. This is because by default anchors with no HREF are ignored. It is far easier to add an
ignoreClass
orignoreSelector
than it is to attach an event to an anchor tag that was excluded.
2.0.0-beta00004
Change Log
- Bug: Fixes #80, reset form not functioning when reset event fired on the form.
- Enhancement: Reduced the amount of code necessary to check for legacy IE browsers to determine which events to attach.
- Documentation: Various documentation corrections/clarifications (see commit log for complete list).
2.0.0-beta00003
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.
1.2.3
Change Log
- Enhancement: Changed header declaration so the window and document object can be passed in, and use ECMAScript 5's strict mode.
- Enhancement: Reworked jQuery .on() method patch for jQuery < 1.7 so it is more concise.
- Bug: Fixed broken stashing support in the default Facebox dialog. The dialog was closing immediately upon restoring from the stash.
- Bug: Fixed missing
</p>
closing tag in the default Facebox dialog. - Bug: Use event.which instead of event.keyCode, since which has been patched in jQuery to work in any browser.
- Bug: Patch for #49 (commit 26fdfec) caused the
beforeunload.dirtyforms
event to fire twice when continuing from the dialog. - Bug: Performance was less than optimal when checking the dirty status because the logic was not set up correctly to exit from unnecessary looping after finding a dirty node.
1.2.2
1.2.1
1.2.0
Change Log
- Bug: Reverted #66 because it is redundant to check for HREF here, duplicate of #59.
- Bug: Reverted #55 because it is redundant to check for HREF here, duplicate of #59.
- Bug: Fixed broken UMD support - plugin was using the jQuery object directly.
- Enhancement: Removed various blocks of redundant and overly verbose code, both to make it easier to maintain and to reduce the number of bytes in the download.
- Bug: Fixes #73 autofocused element not being marked dirty when changed.
- Enhancement: Made the bind, stash, refire, and selector members optional for dialogs. This will make them easier to implement.
- Feature: Closes #77, added support for ignoring child elements of containers (such as
<div>
and<form>
elements). - Bug: Fixes #45, escape key causing the beforeunload event to unregister with the default Facebox dialog. Added the fix (to capture the escape key, cancel the event, and call
$.DirtyForms.choiceCancel()
) to the documentation, since it applies to all dialogs. - Enhancement: Changed the build script to remove the logging code (debug feature) from the minified JavaScript to remove some 1300 bytes from the file. Logging is still available in the uncompressed file.
- Bug: Clicking on a blank target was causing the onbeforeunload event to unregister.
- Enhancement: Reformatted the readme to make it easier to visually parse.