Skip to content

Commit fde16c7

Browse files
BurgovBart van den Burg
authored and
Bart van den Burg
committed
Make sure the form controller keeps it's pristinity, even if initSelection is defined
1 parent dad4e19 commit fde16c7

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
@@ -157,8 +157,13 @@ angular.module('ui.select2', []).value('uiSelect2Config', {}).directive('uiSelec
157157
var initSelection = opts.initSelection;
158158
opts.initSelection = function (element, callback) {
159159
initSelection(element, function (value) {
160+
var isPristine = controller.$pristine;
160161
controller.$setViewValue(convertToAngularModel(value));
161162
callback(value);
163+
if (isPristine) {
164+
controller.$setPristine();
165+
}
166+
elm.prev().toggleClass('ng-pristine', controller.$pristine);
162167
});
163168
};
164169
}

0 commit comments

Comments
 (0)