I can’t find any good resources on how custom events in jquery are actually implemented. Like how they simulate the event bubbling, etc.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This way:
What’s going on here is as follows:
When
triggeris called jQuery checks to see if the event is being triggered globally ($.trigger("event_name");).If it is not being triggered globally, and propagation has not been stopped and the element in question has a parent element (
!event.isPropagationStopped() && parent) then jQuery calls the trigger event manually on the parent element.There is quite a bit more going on — see event.js in the jQuery source code.