event-bubbling

If you delete a DOM element, do any events that started with that element continue to bubble?

允我心安 提交于 2019-11-27 01:34:54
问题 What behavior should I expect if I delete a DOM element that was used to start an event bubble, or whose child started the event bubble - will it continue to bubble if the element is removed? For example - lets say you have a table, and want to detect click events on the table cells. Another piece of JS has executed an AJAX request that will eventually replace the table, in full, once the request is complete. What happens if I click the table, and immediately after the table gets replaced by

jQuery stopPropagation bubble down

大兔子大兔子 提交于 2019-11-27 01:02:23
I have a div with a link inside of it: <div id="myDiv"> <a href="http://www.lol.com">Lol</a> </div> Clicking the <div /> should go somewhere, but clicking the child <a /> should go to www.lol.com. I've seen from previous questions and the jQuery website that .stopPropagation prevents bubbling upwards, but how do I prevent a bubble downwards (isn't that what's necessary here?). Geoff Events only bubble up. So the click event handler for the a element is fired before the click event handler for the div . If you want the behaviour you describe, the you need to add a click event handler to the a

Bubbling scroll events from a ListView to its parent

☆樱花仙子☆ 提交于 2019-11-26 20:13:38
In my WPF application I have a ListView whose ScrollViewer.VerticalScrollBarVisibility is set to Disabled . It is contained within a ScrollViewer . When I attempt to use the mouse wheel over the ListView , the outer ScrollViewer does not scroll because the ListView is capturing the scroll events. How can I force the ListView to allow the scroll events to bubble up to the ScrollViewer ? You need to capture the preview mouse wheel event in the inner listview ctl.PreviewMouseWheel += PreviewMouseWheel; then stop the event from scrolling the listview and raise the event in the parent listview.

Javascript : How to enable stopPropagation?

99封情书 提交于 2019-11-26 20:00:46
问题 With object.stopPropagation() I can stop event bubbling but how can I re-enable it? Is there a pre defined function in js something like object.startPropagation ? EDIT: The Problem is that the JS remembers if you click on the "object" than stop Event Bubbling always even after I don't want it, so I would like to stop it: document.getElementById("object").onclick = function(e){ if(e && e.stopPropagation) { e.stopPropagation(); } else { e = window.event; e.cancelBubble = true; } } 回答1: It doesn

Javascript with jQuery: Click and double click on same element, different effect, one disables the other

元气小坏坏 提交于 2019-11-26 17:42:36
I have an interesting situation - I have a table row which, currently, shows it's hidden counterpart when I click the "Expand" button. The original (unhidden) row which contains the expand button also has some content in a certain cell which, when clicked, becomes editable. I would like to be rid of the expand button, and enable expanding of the row via doubleclick anywhere in the row itself, including the field that turns editable when you click it. You can smell the trouble here already. When I double click a row, two click events are fired first, before the dblclick occurs. This means if I

Is bubbling available for image load events?

帅比萌擦擦* 提交于 2019-11-26 16:41:22
问题 Can I use: window.addEventListner(); in some way. All my images have a display = 'none' . Once the image has loaded, I want to set display = 'inline' This way I can normalize what is displayed while the image is being downloaded. In this case, I can not pre-load my images. 回答1: The load / onload event does not bubble (reference, reference), so what you're asking for is not possible . You'll have to attach an event handler to each image node, or intercept the event during the capture phase, as

capture click on div surrounding an iframe

偶尔善良 提交于 2019-11-26 16:34:51
How can i capture a click or mousedown event on a div surrounding an iframe. I've tried attaching the funciton to click event on the div but since the iframe never bubbles the event up to the surrounding div the function is never called. Is there a way i can capture the event on the div and then propagate it to the iframe for default action If the click is in the iframe area, the iframe context handles the click event, it does not bubble up to the iframe parent. So the div will never register the click event at all if it happened in the iframe area. Furthermore, if the iframe contains a page

How to stop events bubbling in jQuery? [duplicate]

此生再无相见时 提交于 2019-11-26 13:44:41
This question already has an answer here: How do I prevent a parent's onclick event from firing when a child anchor is clicked? 18 answers How do I stop custom event bubbling in jQuery? For example I have this code: $('.myclass').bind('amodaldestroy', function(){ ....does something..... }) How do I only allow this to be triggered once on the first element it finds when bubbling? Can I just add return false ? $('.myclass').bind('amodaldestroy', function(){ ....does something..... return false; }) According to jQuery's documentation : $('myclass').bind('amodaldestroy'), function(event) { ...

How do I hide an element on a click event anywhere outside of the element?

霸气de小男生 提交于 2019-11-26 11:11:43
I would like to know whether this is the correct way of hiding visible elements when clicked anywhere on the page. $(document).click(function (event) { $('#myDIV:visible').hide(); }); The element (div, span, etc.) shouldn't disappear when a click event occurs within the boundaries of the element. Jeremy B. If I understand, you want to hide a div when you click anywhere but the div, and if you do click while over the div, then it should NOT close. You can do that with this code: $(document).click(function() { alert("me"); }); $(".myDiv").click(function(e) { e.stopPropagation(); // This is the

Example for Bubbling and Capturing in React.js

六月ゝ 毕业季﹏ 提交于 2019-11-26 09:36:34
问题 I am looking for an example in handling Bubbling and Capturing in React.js. I found one with JavaScript, but I am having trouble finding the equivalent for React.js. How would I have to create an example for Bubbling and Capturing in React.js? 回答1: Bubbling and capturing are both supported by React in the same way as described by the DOM spec, except for how you go about attaching handlers. Bubbling is as straightforward as with the normal DOM API; simply attach a handler to an eventual