Skip to content

Instantly share code, notes, and snippets.

@vincicat
Created December 2, 2011 10:22
Show Gist options
  • Save vincicat/1422705 to your computer and use it in GitHub Desktop.
Save vincicat/1422705 to your computer and use it in GitHub Desktop.
jQuery 1.7 event data access
// Source: http://jsbin.com/erirek/
$( function() {
var $hello = $( "#hello" ).click( function() {
alert( "hello world" );
});
// does NOT return object the inclues the events property
// pre-1.7 this used to include the events property
console.log( $hello.data() );
// does return events object
// code was added to 1.7+ to get at the events if you explicitly ask for it
console.log( $hello.data( "events" ) );
// does return object that includes the events property
// internal method, not documented
console.log( $._data( $hello[ 0 ] ) );
// does return evetns object
// internal method, not documented
console.log( $._data( $hello[ 0 ], "events" ) );
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment