0

I am creating a single page app with a lot of tooltips and pop ups on different areas. I am closing those elements by checking where the click is happening. for exmaple something like:

$scope.popup1 = {
    open: function(){

        $scope.popup1Open = true;


        $timeout(function(){
            $document.bind('click',function(e){
                if(!angular.element('#popup1-container').find(e.target).length) {
                // if in directive, ill use: $elem.find(e.target).length

                    $timeout(function(){
                        $scope.popup1.close();
                        $scope.$apply();
                    });
                }
            });   

        });

    },

    close: function () {
        $scope.popup1Open = false;
    }
}

Now like I said I have multiple popups happening, which can be opened at different areas of the page. They all have their own ids and some in their own directives. So I'm creating $document.bind('click') each time when a popup opens, and I'm not going to bother unbinding it because it will a) affect the other popups and also the popups are accessed so many times for very key areas.

So my question is, are there any performance issue that might come up with what I'm doing?

muudless
  • 7,422
  • 7
  • 39
  • 57
  • 1
    It's possible to unbind a specific event handler: http://stackoverflow.com/a/23034515/2887841 – tasseKATT Nov 15 '14 at 06:01
  • @tasseKATT i know, but there are times when multiple popups are opened and working with eachother, if i unbind the click after one closes, the other 2 wont close. – muudless Nov 15 '14 at 06:17

0 Answers0