A light-weight jQuery "dirty forms" Plugin - it monitors html forms and alerts users to unsaved changes if they attempt to close the browser or navigate away from the page. (Are you sure?)
508
stars
145
forks
source link
rescan() method changes field orig value if it was empty #123
var rescan = function() {
var $form = $(this);
var fields = $form.find(settings.fieldSelector);
$(fields).each(function() {
var $field = $(this);
if (!$field.data('ays-orig')) {
storeOrigValue($field);
$field.bind(settings.fieldEvents, checkForm);
}
});
// Check for changes while we're here
$form.trigger('checkform.areYouSure');
};
Above is the rescanmethod. On line 6, the expression returns true if
the field's data attribute (ays-orig) is undefiend, or
the field's value is empty
In reality, fields may be empty when page is loaded for the first time. Running this method will lose the original ays-orig values of those fields.
Is there any reason why empty fields have to update their ays-orig values?
Above is the
rescan
method. On line 6, the expression returns true ifthe field's data attribute (ays-orig) is undefiend, or
the field's value is empty
In reality, fields may be empty when page is loaded for the first time. Running this method will lose the original ays-orig values of those fields.
Is there any reason why empty fields have to update their ays-orig values?