angularjs-dropdown-multiselect
angularjs-dropdown-multiselect copied to clipboard
document click event when closeOnBlur
The document click event is not removed on element distroy. In fact, document click event must registred on open event si unregistred on destroy and close. And code look something like this:
var documentClick = function (e) {
console.log("documetn click");
var target = e.target.parentElement;
var parentFound = false;
while (angular.isDefined(target) && target !== null && !parentFound) {
if (_.includes(target.className.split(' '), 'multiselect-parent') && !parentFound) {
if (target === $dropdownTrigger) {
parentFound = true;
}
}
target = target.parentElement;
}
if (!parentFound) {
$scope.$apply(function () {
$scope.open = false;
$document.off('click', documentClick);
});
}
};
$element.on("$destroy", function () {
$document.off('click', documentClick);
});
$scope.toggleDropdown = function () {
$scope.open = !$scope.open;
if ($scope.settings.closeOnBlur) {
if ($scope.open) {
$document.on('click', documentClick);
} else {
$document.off('click', documentClick);
}
}
};
This issue is high on my prio list
any update on this issue? @pkempenaers
ok, I saw the new code, thanks.@pkempenaers
Where's the new code, I didn't see code to unregister the event even in the latest version? @lzynihao @pkempenaers