-1

Hi working with CRM Dynamics 2015 and i want to check in my javascript code if event handler was already added before I add it once more Thanks

Sergey
  • 1
  • possible duplicate of [How to check whether dynamically attached event listener exists or not?](http://stackoverflow.com/questions/11455515/how-to-check-whether-dynamically-attached-event-listener-exists-or-not) – Bhojendra Rauniyar Jul 15 '15 at 11:16
  • I not working with regular document element, I am use Xrm that exist in SDK – Sergey Jul 15 '15 at 11:21
  • Just curious - how could that be that your application doesn't know has event handler attached already or not? – Andrew Butenko Jul 15 '15 at 12:21
  • I run script that add event handler to element when other element's value was changed, in case if value changed once then handler was added and no need to add it again – Sergey Jul 15 '15 at 13:15

1 Answers1

-1

You can get a list of events currently assigned to an element by using the following JQuery code.

$._data( $('.element')[0], 'events' );

If element has no events, it returns "undefined"

Edit:

If you're looking for native solutions see this link How to find event listeners on a DOM node when debugging or from the JavaScript code?

Community
  • 1
  • 1
Mouneer
  • 12,827
  • 2
  • 35
  • 45