Questions tagged [stoppropagation]

stopPropagation is a method of the event object that prevents further propagation of the current event.

stopPropagation is a method of the event object that prevents further propagation of the current event. This prevents ancestors of the current node from receiving the event.

392 questions
1104
votes
9 answers

What's the difference between event.stopPropagation and event.preventDefault?

They seem to be doing the same thing... Is one modern and one old? Or are they supported by different browsers? When I handle events myself (without framework) I just always check for both and execute both if present. (I also return false, but I…
Rudie
  • 52,220
  • 42
  • 131
  • 173
76
votes
4 answers

How can I make an AngularJS directive to stopPropagation?

I am trying to "stopPropagation" to prevent a Twitter Bootstrap navbar dropdown from closing when an element (link) inside an li is clicked. Using this method seems to be the common solution. In Angular, seems like a directive is the place to do…
Robert Christian
  • 18,218
  • 20
  • 74
  • 89
45
votes
4 answers

How do I stop/end/halt a script in R?

I wrote a script that should stop execution if the supplied data is incorrect. However, although stop produces an error message, the script just continues. A minimal example: if (TRUE) {stop("End of script?")} #It should stop here print("Script did…
RHA
  • 3,677
  • 4
  • 25
  • 48
22
votes
4 answers

jQuery on() stopPropagation not working?

I can't seem to get this to stop propagating.. $(document).ready(function(){ $("body").on("click","img.theater",function(event){ event.stopPropagation(); $('.theater-wrapper').show(); }); // This…
Dylan Cross
  • 5,918
  • 22
  • 77
  • 118
18
votes
3 answers

event.preventDefault vs event.stopPropagation

Can someone explain what's the difference between event.preventDefault() and event.stopPropagation()? I have a table and within that table I have an img tag. When I click the img tag, I want to see a popup. But I also want to stop the selection of…
Ionut Flavius Pogacian
  • 4,750
  • 14
  • 58
  • 100
16
votes
4 answers

How to disable scrolling in outer elements?

I have a vertically-scrolling div within a page that also scrolls vertically. When the child div is scrolled with the mouse wheel and reaches the top or bottom of the scroll bar, the page (body) begins to scroll. While the mouse is over the child…
ericsoco
  • 24,913
  • 29
  • 97
  • 127
15
votes
3 answers

stopPropagation and startPropagation

I want to make an additional click handler (client page, cant modify his js/html) and it should work like this in my script: 1) event.stopPropagation (pause client click propagation) 2) my function (do my function, when everything is done do…
Piotr Wu
  • 1,362
  • 3
  • 14
  • 31
15
votes
1 answer

StopPropagation() with SVG element and G

I created an SVG element with an .on("click") behavior and appended g elements with .on("click") and thought that I could use d3.event.stopPropagation() to keep the SVG click event from firing with the g click event. Instead, both events continue to…
Elijah
  • 4,609
  • 3
  • 28
  • 36
13
votes
2 answers

stopPropagation without jQuery

I bind to a link (by using the .live() function of jQuery) click event and then manually add an onclick event handler with pure JS and HTML (like ). I want to prevent bubbling of the event to the live method but…
abonec
  • 1,379
  • 1
  • 14
  • 23
13
votes
4 answers

can someone explain how this stopPropagation works?

I was trying to setup this "when you click outside of the element, close it" type of thing using some code I found on Stackoverflow: $(document).click(function() { $('.list-to-hide').hide(); }); $('.show-list-button').click(function(event) { …
Matt
  • 247
  • 1
  • 4
  • 12
11
votes
2 answers

Is it possible to stop propagation by CSS?

With Javascript it is possible to stop propagation with code? E.g. function func1(event) { alert("DIV 1"); if (document.getElementById("check").checked) { event.stopPropagation(); } } Is it also possible to stop propagation…
Max Lindner
  • 171
  • 1
  • 1
  • 7
11
votes
2 answers

How to stop event capturing in javascript?

We can use event.stopPropagation() for stopping event bubbling. Can we use same method for stopping event capturing also? If no how can we achieve it?
Anusha Nilapu
  • 1,243
  • 8
  • 24
  • 36
11
votes
3 answers

evt.preventDefault is not working in IE and Edge on mouse move event, even tried evt.returnValue = false; but didn't work to stop propagation

I have a re sizable div. While trying to resize it the whole page is getting selected with blue color even though I didn't intend to in iE and Edge. I have tried many solutions shown on web but nothing worked. Below is my code. I am unable to…
Labeo
  • 5,831
  • 13
  • 47
  • 77
11
votes
2 answers

RxJava - How to stop (and resume) a Hot Observable (interval)?

I have the following Hot Observable: hotObservable = Observable.interval(0L, 1L, TimeUnit.SECONDS) .map((t) -> getCurrentTimeInMillis())) However, I can't find a good way to stop it. I was able to partially solve this…
11
votes
5 answers

stopPropagation() with tap event

I'm using hammer.js and it appears that I event.stopPropagation() doesn't work with tap event. If I click on the child, the associated event is triggered but parent's event is also triggered and I don't want that. $('#parent').hammer().bind('tap',…
TimPetricola
  • 1,491
  • 2
  • 12
  • 24
1
2 3
26 27