Skip to content
This repository was archived by the owner on Sep 8, 2020. It is now read-only.

Commit dc1899b

Browse files
author
Dmitry Dedukhin
committed
Keep pristine state when attached to input tag
1 parent 42712d2 commit dc1899b

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/select2.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,14 @@ angular.module('ui.select2', []).value('uiSelect2Config', {}).directive('uiSelec
206206

207207
// Not sure if I should just check for !isSelect OR if I should check for 'tags' key
208208
if (!opts.initSelection && !isSelect) {
209+
var isPristine = controller.$pristine;
209210
controller.$setViewValue(
210211
convertToAngularModel(elm.select2('data'))
211212
);
213+
if (isPristine) {
214+
controller.$setPristine();
215+
}
216+
elm.prev().toggleClass('ng-pristine', controller.$pristine);
212217
}
213218
});
214219
};

0 commit comments

Comments
 (0)