diff --git a/src/select2.js b/src/select2.js index 828032d..33262e4 100644 --- a/src/select2.js +++ b/src/select2.js @@ -124,7 +124,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); } @@ -206,13 +206,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); } }); diff --git a/test/karma.conf.js b/test/karma.conf.js index b5658bc..d5f21b3 100644 --- a/test/karma.conf.js +++ b/test/karma.conf.js @@ -15,7 +15,7 @@ module.exports = function(config) { // list of files / patterns to load in the browser files: [ // Dependencies - 'bower_components/jquery/jquery.js', + 'bower_components/jquery/dist/jquery.js', 'bower_components/angular/angular.js', 'bower_components/angular-mocks/angular-mocks.js', 'bower_components/select2/select2.js',