Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to undo event.stopPropagation in jQuery?

I'm using event.stopPropagation() in my application. There has appeared, however, one scenario where I want the propagation to continue as if the aforementioned function was never called. So I'm wondering; is there a way to "resume" propagation after it's been stopped? It would be terribly tedious to move the one call to event.stopPropagation to a dozen separate conditional statements.

like image 860
Hubro Avatar asked Feb 17 '12 08:02

Hubro


People also ask

What is event stopPropagation () in jquery?

The event. stopPropagation() method stops the bubbling of an event to parent elements, preventing any parent event handlers from being executed. Tip: Use the event. isPropagationStopped() method to check whether this method was called for the event.

How do I reset event preventDefault?

submit(function(event) { event. preventDefault(); return false; }); } }); function validateField() { var first_name = $('#first_name').

How do I stop events bubbling?

If you want to stop the event bubbling, this can be achieved by the use of the event. stopPropagation() method. If you want to stop the event flow from event target to top element in DOM, event. stopPropagation() method stops the event to travel to the bottom to top.


1 Answers

Once propagation has been stopped, it cannot be resumed. As a workaround, what you can do is set a variable, and then only stop if this variable is true:

var stop = false;
// do your logic here
if(stop){
    event.stopPropagation();
}
like image 184
Schiavini Avatar answered Nov 15 '22 20:11

Schiavini