Skip to content

Instantly share code, notes, and snippets.

@dvtng
dvtng / jquery.prebind.js
Created June 27, 2011 23:51 — forked from jonathanconway/jquery.prebind.js
preBind() - Add an event binding *before* any pre-existing bindings. (An early version, may not work in all scenarios)
$.fn.preBind = function(type, data, fn) {
this.bind(type, data, fn);
var currentBindings = this.data('events')[type];
this.data('events')[type] = currentBindings.slice(-1)
.concat(currentBindings.slice(0, -1));
return this;
};