0

I want to make my menu off when click anywhere else in the window. Here is the JS function I have written.

  $document.on('click', menuClickHandler);
     this.$onDestroy = function (){$document.off('click');}

              function menuClickHandler(event) {
            var target = event.target;
            if (!target.className.includes("icon-more more-icon")) {
                self.isMenuOpen = false;
            }
        }

Code is working but menu gets closed when clicked outside for two times. I want to close the menu on a single click when clicked outside. Please help !

0 Answers0