component.js
function (obj, eventType, eventHandler) {
			if (!obj.eventHandlers) { obj.eventHandlers = {}; }
			if (!obj.eventHandlers[eventType]) {
				obj.eventHandlers[eventType] = [];
			}
			if (eventHandler) {
				obj.eventHandlers[eventType].push(eventHandler);
			}
			return obj.eventHandlers[eventType];
		}
function (obj, eventType, eventHandler) {
			if (!obj.eventHandlers) { obj.eventHandlers = {}; }
			if (!obj.eventHandlers[eventType]) {
				obj.eventHandlers[eventType] = [];
			}
			if (eventHandler) {
				obj.eventHandlers[eventType].push(eventHandler);
			}
			return obj.eventHandlers[eventType];
		}
function ( obj , eventType , eventHandler ) { if ( ! obj . eventHandlers ) { obj . eventHandlers = { } ; } if ( ! obj . eventHandlers [ eventType ] ) { obj . eventHandlers [ eventType ] = [ ] ; } if ( eventHandler ) { obj . eventHandlers [ eventType ] . push ( eventHandler ) ; } return obj . eventHandlers [ eventType ] ; }
Adds an event handler to a componet
@param {object} obj - Target object
@param {string} eventType - Name of the event
@param {function} eventHandler - Event handler
@return {object} - Object with a list of defined event handlers
Adds an event handler to a componet