Skip to content

Instantly share code, notes, and snippets.

@dvtng
Forked from jonathanconway/jquery.prebind.js
Created June 27, 2011 23:51
Show Gist options
  • Save dvtng/1050145 to your computer and use it in GitHub Desktop.
Save dvtng/1050145 to your computer and use it in GitHub Desktop.
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;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment