How to check if some DOM element in another DOM element tree? For example to hide menu when you click on main page content instead of menu you can: Note that usual solution to hide menu when you click to non-menu area is event.stopPropagation() on menu and non-conditional document.addEventListener(). I make test code with iteration loop over node = node.parentNode
Tag: dom-events
Mobile Safari sometimes does not trigger the click event
This is a dynamic JavaScript application I am working on. I have many <a> anchor elements that have a class. When that class is clicked, something should happen. This works fine in Firefox, Chrome, IE, but in some cases the click event is not triggered on mobile Safari (iPad and iPhone). These elements all have exactly the same CSS, it’s
Javascript: cancel or let an event continue?
My scenario deals with Kendo UI, but I think it probably applies to JavaScript generally, hence the JavaScript tag. I have a Kendo scheduler with the edit event option set to functionA. In functionA, I create a Kendo window (basically a modal) that asks the user a question; in one case the edit event should continue and bubble up as
How to unbind $on in Angular?
I have a code that use $scope.$on one time on init and then in a function, so the code is executed multiple times. How can I unbind if first before I bind it again. I’ve try $scope.$off but there’s not such function, https://docs.angularjs.org/api say nothing about $on. I’m using angular 1.0.6. Answer If you don’t un-register the event, you will
JavaScript unwanted event auto-triggered
The on click event in the 70 line (ob.addEventListener(“click”,onCl1(idTable[0],idTable));) is being triggered without a reason. I have tried some other ways and it still reacts the same. I present the whole code as I think that it will be easier to find this bug: Answer It’s because you’re calling your event handler function instead of passing a function when you
Load different content onclick of different controls
I am trying to load different content onclick of different button controls. Since I am new to JavaScript and don’t know where I am doing wrong. It will be highly appreciated if there is any help from any one of you! The code of which is here: and the HTML code is here: and same code is on jsfiddler as
What does it mean by “message queue” in this link?
I was trying to understand what’s an event loop in JavaScript. Came across Mozilla Developer Network’s link about event loop. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/EventLoop It mentions Queue A JavaScript runtime contains a message queue, which is a list of messages to be processed. To each message is associated a function. When the stack is empty, a message is taken out of the queue
What version of IE doesn’t pass the event as argument to listeners?
As some old versions of IE didn’t provide the event as argument to event listeners, we got used to (event||window.event). In order to decide whether it can still make some sense to have this in a modern library, I tried to look at what versions were concerned but I couldn’t find this information. So, what’s the most recent version of
Copying JS events from one element to another
I’m attempting to copy events from one element, to another using pure JS (i.e. not JQuery). The bug I’m hitting, is when there’s multiple events, the last event is used for both. Bit hard to explain, please refer to my jsbin example, I want to copy the mousedown and mouseup events from #foo to #bar. The bug is, the mouseup
Expanding “Activate Later” functionality
I would like to call some implemented validation Javascript method When I click on the Button “Activate Later” (see the pic). Any Idea how to do this? Answer You will need to overlay the siteadmin at /libs/wcm/core/content/siteadmin. Just copy that node structure and place it at /apps/wcm/core/content/siteadmin. Then navigate to /apps/wcm/core/content/siteadmin/actions/activate/menu/activateLater and place your javascript function in the handler property.