Obsessive/Compulsive re: Events
Friends,
I fear I'm losing site of the forest, but...in a project, I've created three functions to handle events:
addListeners() addEvent(element, eventType, functionName) eventHandler(e)
and an XML file to store event info for the elements:
<root> <element id='txt09'> <event name='blur' /> <event name='focus' /> <event name='keydown' /> </element> <element id='txt10'> <event name='blur' /> <event name='focus' /> <event name='keydown' /> </element> <element id='txt11'> <event name='blur' /> <event name='focus' /> <event name='keydown' /> </element> <element id='spanAllItem'> <event name='dblclick' /> </element> <element id='spanDocItem'> <event name='dblclick' /> </element> <element id='thDocItem'> <event name='click' /> <event name='mouseover' /> <event name='mouseout' /> </element> </root>
addListeners loads the XML file, parses it, and calls addEvent to assign the event to the element(s) found within.
eventHandler is invoked when any of the elements fire an event; it decodes the element and through switch() blocks determines what to do.
Am I taking things too far, when I could just as well code 'onClick()', 'onBlur()', etc. directly into the HTML element declarations?
Or does abstracting things in this way make sense?
tia INVALID ARGUMENT*** |