Why does jQuery event model does not support event Capture and just supports event bubbling?
Event Bubbling − Whenever an event happens on an element, the event handlers will first run on it and then on its parent and finally all the way up to its other ancestors. Event Capturing − It is the reverse of the event bubbling and here the event starts from the parent element and then to its child element.
Event bubbling directs an event to its intended target, and works like this: When an object (like a button) is clicked, an event is directed to the object. If an event handler is set for the object, the event handler is triggered. Then the event bubbles up (like a bubble in water) to the objects parent.
Because not all browsers support event capturing, especially IE. As jQuery is supposed to be cross-browser compatible, it cannot offer event capturing (it might be possible to simulate event capturing, but if it were easy, I'm sure they would have done it).
This was infact a desirable feature in jQuery 2 but the core-team was pretty much convinced that allowing capturing events to have equal standing throughout the entire jQuery event system would open up a whole lot of issues. The original ticket can be found here[1]. They even closed the ticket after few discussions.
Moreover, browsers older then IE8 and Opera 7.0 does not support event capturing. Since the primary goal of jQuery is to provide cross-browser support, it does not support event capturing.
On a lighter note, it seems jQuery is more focused to leverage Event Delegation which is based on bubbling of events up to the DOM tree.
[1] http://bugs.jquery.com/ticket/14953
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With