Trip
Trip

Reputation: 27114

How do you inspect events bound with .on() with jQuery 1.7+?

The old version of doing this doesn't seem to work..

$(".object").data('events');

..when I bind with this :

$(document).on("click", ".object", awesomePossumFunction() );

This does not show the events :

$(".object").data('events');

Upvotes: 3

Views: 256

Answers (3)

Kevin B
Kevin B

Reputation: 95022

I suggest you not use .data('events'), it has been removed from newer versions of jQuery. You can access it at it's new location in newer versions of jQuery, but that also isn't suggested as it is subject to change.

Reference: http://bugs.jquery.com/ticket/10589

The important bits from that ticket is that in 1.7, changes to the event object were made that caused code that used .data('events') to not function properly. The new location is jQuery._data(elem, "events")

Fiddle: http://jsfiddle.net/6PxFx/

Upvotes: 3

adeneo
adeneo

Reputation: 318212

It should work just fine if you check for events on the actual element it was bound to:

$(document).on("click", ".object", awesomePossumFunction); //binds to document

var events  = $.data(document, 'events');  //jQuery 1.7.2 and below
var events2 = $._data(document, 'events'); //jQuery 1.8 ++

FIDDLE

Upvotes: 2

eduard
eduard

Reputation: 1495

Your second line is something I never used. The handler might not be registered where you want it to. I would do this instead:

$(".object").on("click", awesomePossumFunction());

Let me know if this was of any good.

Upvotes: 0

Related Questions