From 04c79652fd9e87c10d8916de28b3741a7119d596 Mon Sep 17 00:00:00 2001 From: garipov Date: Fri, 14 Nov 2014 13:17:34 +0300 Subject: [PATCH 1/2] Add selectize.destroy() It's need to remove drop-down block, when it has been created in other container which set in dropdownParent option. --- angular-selectize.js | 1 + 1 file changed, 1 insertion(+) diff --git a/angular-selectize.js b/angular-selectize.js index 3b4947b..44125cd 100644 --- a/angular-selectize.js +++ b/angular-selectize.js @@ -250,6 +250,7 @@ if (updateTimer) { $timeout.cancel(updateTimer); } + if ( selectize ) selectize.destroy(); }); } }; From 8f5d468719e44116cb80b4192091bb7c4eacb8c7 Mon Sep 17 00:00:00 2001 From: garipov Date: Wed, 19 Nov 2014 17:54:49 +0300 Subject: [PATCH 2/2] Subscribe to scope.destroy if no ng-options --- angular-selectize.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/angular-selectize.js b/angular-selectize.js index 44125cd..78c87b5 100644 --- a/angular-selectize.js +++ b/angular-selectize.js @@ -42,6 +42,7 @@ var selectize, newModelValue, newOptions, updateTimer; watchModel(); + subscribeToScopeDestroy(); if (attrs.ngDisabled) { watchParentNgDisabled(); @@ -246,12 +247,14 @@ return displayFn(optionContext); } - scope.$on('$destroy', function() { - if (updateTimer) { - $timeout.cancel(updateTimer); - } - if ( selectize ) selectize.destroy(); - }); + function subscribeToScopeDestroy() { + scope.$on('$destroy', function () { + if (updateTimer) { + $timeout.cancel(updateTimer); + } + if (selectize) selectize.destroy(); + }); + } } }; }]);