iegorov
12/8/2014 - 8:27 AM

How to find event listeners on a DOM node in prototype

How to find event listeners on a DOM node in prototype

/**
 * Things are now routed through Element storage : )
 * Element.getStorage(yourElement).get('prototype_event_registry') will give you an instance of Prototype's Hash, so you can do anything that you would do with hash.
*/
// to see which event types are being observed
Element.getStorage(yourElement).get('prototype_event_registry').keys();

// to get array of handlers for particular event type
Element.getStorage(yourElement).get('prototype_event_registry').get('click');

// to get array of all handlers
Element.getStorage(yourElement).get('prototype_event_registry').values();

// etc.