I'm in the need of widen my perspective on the framework libraries, to be able to make well aware choices of if/which/when to add a framework to a website.
One thing that got my attention was event handlers, as they seems to be somewhat more complex structured.
For me, in the early days, an event handler were added inline with its element <a onclick="DoSomething();">...</a>
Later on they were removed from being inline and added globally document/element.onlick = "DoSomethingOnClick
or document/element.onlick = "function() {...}
As of today, the frameworks add their own mechanism on top and I am trying to grasp what/how that actually means/is done.
By studying code parts it appears to me, and here describe in a VERY simple way, that they add the onclick
event similar to above global and then pass the event when raised, into their own handler, which itself is an object structure containing stored/added functions and elements and their relationships.
Is this a correct observation? If not, then how is it done?
Can this be showed with a simple written sample in Javascript?
Based on the following quote,
"You can use the jQuery on method to attach an event handler to the document, and pass it a filter string that will cause your handler only to fire when the event happens on an element that match the filter, and with the matched element as this value."
how is the element that triggered the event identified in the handler (by the event object or ?) and how are the elements to be fired stored/identified?
Do the other frameworks, other than jQuery, have a very much different structure of their implementation of event handlers?