From 2e9f71a1926b9a96b262703cc1bd0d1bf4c80efd Mon Sep 17 00:00:00 2001 From: Martin Hradil Date: Fri, 14 Oct 2016 11:45:17 +0000 Subject: [PATCH] pfSelect - destroy the selectpicker when the directive is destroyed Since patternfly 3.8, the structure of the HTML generated by the selectpicker has changed, and removing the original select element no longer necessarily removes the selectpicker div that's actually visible. This makes pf-select explicitly destroy the selectpicker when the element with that pf-select is going away. (Related to ManageIQ/manageiq#11893) --- src/select/select.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/select/select.js b/src/select/select.js index 0dca51439..ca5277332 100644 --- a/src/select/select.js +++ b/src/select/select.js @@ -81,6 +81,10 @@ angular.module('patternfly.select', []).directive('pfSelect', function ($timeout }); }; + var selectpickerDestroy = function () { + element.selectpicker('destroy'); + }; + element.selectpicker(scope.selectPickerOptions); ngModel.$render = function () { @@ -101,6 +105,8 @@ angular.module('patternfly.select', []).directive('pfSelect', function ($timeout } attrs.$observe('disabled', selectpickerRefresh); + + scope.$on('$destroy', selectpickerDestroy); } }; });