Skip to content

Commit 1602c52

Browse files
committed
Disabled field handling: use a static marker rather than appending a
value. This means that if a disabled field is enabled, the value is changed, then disabled again, the form is not considered dirty (because the value is still not going to be submitted). Prior to this change, the form would be considered dirty as the new value was appended to the marker. As the value is no longer used the disabled check is now made earlier.
1 parent 36d3e9d commit 1602c52

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

jquery.are-you-sure.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,14 @@
2727
return null;
2828
}
2929

30+
if ($field.is(':disabled')) {
31+
/*
32+
* Given disabled fields don't submit we use a static marker (and the real value is ignored). If the field is
33+
* later enabled the actual value will be used and the form will become dirty.
34+
*/
35+
return 'ays-disabled';
36+
}
37+
3038
var val;
3139
var type = $field.attr('type');
3240
if ($field.is('select')) {
@@ -51,11 +59,6 @@
5159
val = $field.val();
5260
}
5361

54-
if ($field.is(':disabled')) {
55-
// for disabled fields we prepend a marker as a simple way to later determine if the disabled state has changed
56-
val = 'ays-disabled-' + val;
57-
}
58-
5962
return val;
6063
};
6164

0 commit comments

Comments
 (0)