Documentation


Implementing the Plugin

As with most jQuery plugins, implementing the plugin with its default settings takes a single line of code. Call the plugin after the selector that denotes the form or container element that encloses all of the form fields you want to track the status of:

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

When used with its default settings, the plugin does the following:

It is up to you to write the CSS code for the "dirtyField" class.

To change those defaults, or to access additional plugin functionality via the callbacks, you can pass in a collection of settings and callbacks as options, like so:

var options= {
denoteDirtyForm: true,
denoteDirtyOptions: true,
trimText:true,
preFieldChangeCallback: function(originalValue) {
    $("#callbackBox").append("preFieldChangeCallback run.  Original value: " + originalValue + "&;lt;br />");
}
};

$("#myForm").dirtyFields(options);

Any settings that you don't pass in will simply default to the setting's default value, and any callbacks you don't define will simply not execute.


Settings

Below is an alphabetical list of all of the optional settings you can use to alter the behavior of the plugin:


Callbacks

The callbacks provided by the plugin are listed below in order of execution:


Public Functions

The plugin comes with a number of public functions to help you utilize the plugin in a number of different scenarios. Each of these functions can be called as a property of the $.fn.dirtyFields object (as shown in the example code).

NOTE: All of these functions require the form or form field container that the plugin was applied to to be passed in as a parameter. You cannot use a different container element for that parameter: it must be the container that the main plugin function dirtyFields() was used with.