Skip to content

Instantly share code, notes, and snippets.

View attila's full-sized avatar

Attila Beregszaszi attila

View GitHub Profile
@attila
attila / jquery.prebind.js
Last active February 21, 2017 00:11 — forked from jonathanconway/jquery.prebind.js
Use $._data to get event data as $(this).data('events') has been removed from jQuery 1.8+
$.fn.preBind = function(type, data, fn) {
this.each(function() {
var $this = $(this);
$this.bind(type, data, fn);
var currentBindings = $._data($this[0], 'events');
if ($.isArray(currentBindings[type])) {
currentBindings[type].unshift(currentBindings[type].pop());
}