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

Commit

Permalink
Merge pull request #215 from MilosMosovsky/fix-dirty-flag
Browse files Browse the repository at this point in the history
Fix incorrect dirty flag when initializing from JSON #151
  • Loading branch information
ProLoser committed Aug 1, 2014
2 parents 2781639 + 4f06595 commit f81cbc8
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/select2.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ angular.module('ui.select2', []).value('uiSelect2Config', {}).directive('uiSelec
$timeout(function () {
elm.select2('val', controller.$viewValue);
// Refresh angular to remove the superfluous option
elm.trigger('change');
controller.$render();
if(newVal && !oldVal && controller.$setPristine) {
controller.$setPristine(true);
}
Expand Down Expand Up @@ -221,13 +221,14 @@ angular.module('ui.select2', []).value('uiSelect2Config', {}).directive('uiSelec

// Not sure if I should just check for !isSelect OR if I should check for 'tags' key
if (!opts.initSelection && !isSelect) {
var isPristine = controller.$pristine;
controller.$setViewValue(
convertToAngularModel(elm.select2('data'))
);
if (isPristine) {
controller.$setPristine();
}
var isPristine = controller.$pristine;
controller.$pristine = false;
controller.$setViewValue(
convertToAngularModel(elm.select2('data'))
);
if (isPristine) {
controller.$setPristine();
}
elm.prev().toggleClass('ng-pristine', controller.$pristine);
}
});
Expand Down

1 comment on commit f81cbc8

@jimmywarting
Copy link

Choose a reason for hiding this comment

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

Can you update bower.js version so we can get this?

Please sign in to comment.