Using the prettyPhoto plugin to open modal-style content containers, and trying to integrate with Google Analytics\' Event Tracking to track when videos get opened.
Worked for me with older and newer jQuery versions:
/**
* @link http://stackoverflow.com/a/26892146/655224
*/
jQuery.fn.getEvents = function() {
if (typeof(jQuery._data) == 'function') {
return jQuery._data(this.get(0), 'events') || {};
} else if (typeof(this.data) == 'function') { // jQuery version < 1.7.?
return this.data('events') || {};
}
return {};
};
jQuery.fn.preBind = function(type, data, fn) {
this.each(function () {
var $this = jQuery(this);
$this.bind(type, data, fn);
var currentBindings = $this.getEvents()[type];
if (jQuery.isArray(currentBindings)) {
currentBindings.unshift(currentBindings.pop());
}
});
return this;
};
But beware, this functions can only return/prebind that events that was set with jQuery itself.
Special thanks to @jonathanconway and @Patrick...