Search code examples
javascriptmootools

see events defined on a MooTools element in console


Is there an easy way to see, in the console, what events are defined for a MooTools element?

For example, if I have a link with id 'link_with_event' on which I've added a click event, is there something like $('link_with_event').events that I could type into the console and see that click even I've defined?

Thanks.


Solution

  • Yes, it's possible through retrieve method. On each mootools Element, events are stored with 'events' key. To display all the events associated with a specific element, just retrieve them :

    var myElement = $('myElement'); //grab elem
    
    myElement.addEvent('click',function(){alert('clicked')}); //add event
    
    console.log(myElement.retrieve('events')); //log added events
    

    demo => http://jsfiddle.net/steweb/5xxcP/