Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions dist/selectize.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ angular.module('selectize', []).value('selectizeConfig', {}).directive("selectiz
}

var onChange = config.onChange,
onOptionClear = config.onOptionClear,
onOptionAdd = config.onOptionAdd;

config.onChange = function() {
Expand Down Expand Up @@ -90,6 +91,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
Expand All @@ -114,7 +128,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;
Expand Down