Introducing jQuery.dirty

Introducing jQuery.dirty

Having previously blogged about checking if a form has been modified I needed something slightly different

I came across dirrty, a jQuery plugin by Ruben Torres that I personally found to have a cleaner implementation than the dirtyFields I previously wrote about.

For instance, to check if a form has unsaved changes is a lot simpler

// dirtyFields
var isFormDirty1 = $.fn.dirtyFields.getDirtyFieldNames($form).length > 0;

// dirrty
var isFormDirty2 = $form.dirrty("isDirty");

Dirrty did most of what I wanted to do but I still needed to extend it further.
And so, jQuery.dirty was born.Check out https://simon-reynolds.github.io/jquery.dirty/ for more. Take a look at the code here

It contains a few extra commands, including

var isFormDirty = $form.dirty("isDirty");

var isFormClean = $form.dirty("isClean");

$form.dirty("resetForm");

$form.dirty("showDirtyFields"); 

To take it for a test drive you can either use git, bower or npm

git clone https://github.com/simon-reynolds/jquery.dirty.git
bower install jquery.dirty
npm install jquery.dirty

Share Tweet Send
0 Comments
Loading...
You've successfully subscribed to SimonReynolds.ie
Great! Next, complete checkout for full access to SimonReynolds.ie
Welcome back! You've successfully signed in
Success! Your account is fully activated, you now have access to all content.