Skip to content

Commit f109611

Browse files
committed
"Improve" the set dirty hack
1 parent dedf3c9 commit f109611

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

fng-bootstrap-datetime.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,16 @@
2020
'date-format': 'dd/MM/yyyy'
2121
};
2222

23-
// Set form to dirty when required. Works OK with existing records - hopefully new records will have other field types
23+
// // Set form to dirty when required. Works OK with existing records - hopefully new records will have other field types
2424
var watchField = attrs.model + '.' + attrs.fngFldName;
2525
var formName = attrs.fngOptName;
2626
scope.$watch(watchField, function (newVal, oldVal) {
2727
if (newVal && oldVal && newVal !== oldVal) {
28-
scope[formName].$setDirty();
28+
var newComp = (typeof newVal === 'string') ? newVal : newVal.toISOString();
29+
var oldComp = (typeof oldVal === 'string') ? oldVal : oldVal.toISOString();
30+
if (newComp !== oldComp) {
31+
scope[formName].$setDirty();
32+
}
2933
}
3034
});
3135

0 commit comments

Comments
 (0)