From 8ceb7bd9b78b7dcbdfb196c6081787ed1b50d64f Mon Sep 17 00:00:00 2001 From: Milos Mosovsky Date: Wed, 21 May 2014 19:48:23 +0200 Subject: [PATCH 1/3] Fix incorrect dirty flag when initializing from JSON #151 --- src/select2.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) 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); } }); From b1120216047089113ce9aff1c9a9179fa70697ac Mon Sep 17 00:00:00 2001 From: Milos Mosovsky Date: Wed, 21 May 2014 20:02:15 +0200 Subject: [PATCH 2/3] Fix incorrect dirty flag when initializing from JSON #151 (fix jquery) , closes #151 --- test/karma.conf.js | 1 + 1 file changed, 1 insertion(+) diff --git a/test/karma.conf.js b/test/karma.conf.js index b5658bc..423c0e3 100644 --- a/test/karma.conf.js +++ b/test/karma.conf.js @@ -16,6 +16,7 @@ module.exports = function(config) { 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', From 4f06595db5cbd7a8ae8f5c43301ed88cc22a8866 Mon Sep 17 00:00:00 2001 From: Milos Mosovsky Date: Wed, 21 May 2014 20:24:48 +0200 Subject: [PATCH 3/3] Fix Jquery --- test/karma.conf.js | 1 - 1 file changed, 1 deletion(-) diff --git a/test/karma.conf.js b/test/karma.conf.js index 423c0e3..d5f21b3 100644 --- a/test/karma.conf.js +++ b/test/karma.conf.js @@ -15,7 +15,6 @@ 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',