This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.fn.preBind = function(type, data, fn) { | |
var currentBindings = this.data('events')[type]; | |
var currentBindingsLastIndex = currentBindings.length - 1; | |
var newBindings = []; | |
// bind the event | |
this.bind(type, data, fn); | |
// move the new event to the top of the array | |
newBindings.push(currentBindings[currentBindingsLastIndex]); |