From bc73c0ffd02f1a5287ae70ee7a7891846388dca6 Mon Sep 17 00:00:00 2001 From: Karanvir Kang Date: Thu, 3 Sep 2015 16:26:16 -0400 Subject: [PATCH 1/2] Fix for issue# 94 Implementing a callback handler for on change event. --- dist/selectize.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/dist/selectize.js b/dist/selectize.js index 5696b4c..fbbdd4e 100755 --- a/dist/selectize.js +++ b/dist/selectize.js @@ -90,6 +90,19 @@ angular.module('selectize', []).value('selectizeConfig', {}).directive("selectiz } } }; + + config.onOptionClear = function () { + if (scope.disableOnOptionClear) + return; + + if (scope.options) { + scope.options.length = 0; + } + + if (onOptionClear) { + onOptionClear.apply(this, arguments); + } + }; if(scope.options){ // replace scope options with generated options while retaining a reference to the same array @@ -114,7 +127,9 @@ angular.module('selectize', []).value('selectizeConfig', {}).directive("selectiz scope.$watch('options', function() { scope.disableOnChange = true; + scope.disableOnOptionClear = true; selectize.clearOptions(); + scope.disableOnOptionClear = false; selectize.addOption(scope.options); selectize.setValue(scope.ngModel); scope.disableOnChange = false; From ab54452f351c295fc6434c2f92522a3931e53a05 Mon Sep 17 00:00:00 2001 From: Karanvir Kang Date: Thu, 3 Sep 2015 20:38:56 -0400 Subject: [PATCH 2/2] Typo fix for issue #94 fix Typo fix --- dist/selectize.js | 1 + 1 file changed, 1 insertion(+) diff --git a/dist/selectize.js b/dist/selectize.js index fbbdd4e..0961f70 100755 --- a/dist/selectize.js +++ b/dist/selectize.js @@ -61,6 +61,7 @@ angular.module('selectize', []).value('selectizeConfig', {}).directive("selectiz } var onChange = config.onChange, + onOptionClear = config.onOptionClear, onOptionAdd = config.onOptionAdd; config.onChange = function() {