Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions jquery.are-you-sure.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
{
'message' : 'You have unsaved changes!',
'dirtyClass' : 'dirty',
'dirtyFieldClass' : 'dirty-field',
'change' : null,
'silent' : false,
'addRemoveFieldsMarksDirty' : false,
Expand Down Expand Up @@ -78,15 +79,21 @@
return (getValue($field) != origValue);
};



var $form = ($(this).is('form'))
? $(this)
: $(this).parents('form');

// Test on the target first as it's the most likely to be dirty
if (isFieldDirty($(evt.target))) {
setDirtyFieldStatus($(evt.target), true);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's better to set this in the "brute force" section, I noticed that rescans won't pickup on this section.

setDirtyStatus($form, true);
return;
}
else {
setDirtyFieldStatus($(evt.target), false);
}

$fields = $form.find(settings.fieldSelector);

Expand Down Expand Up @@ -135,6 +142,11 @@
}
};

var setDirtyFieldStatus = function($field, isDirty){
$field.toggleClass(settings.dirtyFieldClass, isDirty);

};

var rescan = function() {
var $form = $(this);
var fields = $form.find(settings.fieldSelector);
Expand Down