0

I'm trying to track down a problem in some very complex Javascript and I need to find all the jQuery(document).ready( events that are active on the current screen as one of them is causing the problem.

Is there any way from the Javascript console to ask jQuery for the list of ready events set up on the document element? I did some googling and tried:

> jQuery(document)
< [#document]

> jQuery(document).data("events")
< undefined

Thanks to @ArunPJohny I now have:

> jQuery._data(document).events

Which returns:

Object {mouseup: Array[1], touchstart: Array[2], touchmove: Array[1], touchend: Array[1], click: Array[1]…}
   MSPointerOver: Array[1]
   click: Array[1]
   mousemove: Array[1]
   mouseup: Array[1]
   pointerover: Array[1]
   touchend: Array[1]
   touchmove: Array[1]
   touchstart: Array[2]
   __proto__: Object
Tim B
  • 40,716
  • 16
  • 83
  • 128
  • 1
    `jQuery._data(document).events` – Arun P Johny Sep 05 '14 at 13:40
  • also see [link .data("events")](http://jquery.com/upgrade-guide/1.9/#data-quot-events-quot-) – Arun P Johny Sep 05 '14 at 13:41
  • `$._data($(document), "events");` – bzeaman Sep 05 '14 at 13:43
  • 1
    @BennoZeeman it should be `$._data(document, "events");` - you need to pass a dom element reference no a jQuery object to `$._data()` – Arun P Johny Sep 05 '14 at 13:43
  • It could be. Doesn't have to be. – bzeaman Sep 05 '14 at 13:44
  • you can test it using SO itself... go to the console and try both of the scripts... `$._data($(document), "events");` returns `undefined` where as `$._data(document, "events");` returns an object – Arun P Johny Sep 05 '14 at 13:45
  • Ok, I'm making progress thank you @ArunPJohny - one more question, I get the list of events but which of these are the document ready event? I don't see any called that. – Tim B Sep 05 '14 at 13:45
  • @Arun P Johny Terribly sorry. I even saw it at this question http://stackoverflow.com/a/2008622/2703418 . Sorry. – bzeaman Sep 05 '14 at 13:46
  • @BennoZeeman you'd have to use `get(0)` to do it the way you suggested `$._data($(document).get(0), "events");` – andrew Sep 05 '14 at 13:48
  • @andrew Which wouldn't make sense, unless you use a selector to get the JQuery object. – bzeaman Sep 05 '14 at 13:49
  • Possible duplicate of [Can I find events bound on an element with jQuery?](https://stackoverflow.com/questions/2008592/can-i-find-events-bound-on-an-element-with-jquery) – freedomn-m Jan 09 '19 at 19:45

0 Answers0