Old blog. Blog moved to thomasgathings.com
I would delete this...but I don't see the option

May 2011 Entries

jQuery plugin for confirming unsaved changes

I dug up one of my first jQuery plugins and thought I would share. //thomas gathings //jquery plugin to enable confirmation of unsaved changes on common input elements. //apply to an ancestor, such as fieldset, div, or form. jQuery.fn.confirmUnsavedCha... = function() { var $obj = this; var saving = false; window.onbeforeunload = function() { //if local element data 'dirty' = true, show unload confirmation if (!saving && $obj.data("dirty")) { return "You have unsaved changes."; } }; //for...