I am trying to hide the DIV when blurring (focus has been removed from the DIV ). I use angular and bootstrap. So far, I have tried to set the “focus” to the DIV when it is displayed, and then the ng-blur function when the user clicks elsewhere on the screen. This does not work.
Basically the problem is that I cannot focus on my " #lockerBox " via JS, my " hideLocker " function does not work when the focus is assigned to my DIV by clicking it.
<div class="lock-icon" ng-click="showLocker(result); $event.stopPropagation();"></div> <div ng-show="result.displayLocker" id="lockerBox" ng-click="$event.stopPropagation();" ng-blur="hideLocker(result)" tabindex="1"> $scope.displayLocker = false; $scope.showLocker = function ( result ) { $scope.displayLocker = !$scope.displayLocker; node.displayLocker = $scope.displayLocker; function setFocus() { angular.element( document.querySelector( '#lockerBox' ) ).addClass('focus'); } $timeout(setFocus, 100); }; $scope.hideLocker = function ( node ) { $scope.displayLocker = false; node.displayLocker = $scope.displayLocker; };
javascript angularjs focus blur
user1876246
source share