/ Published in: jQuery
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
(function($) { $.fn.bindIntoStack = function(namespace, func, pos) { var evt = namespace.split('.').shift(); return this .each(function() { var $this = $(this); $this.bind(namespace, func); var newOrder = new Array(); $.each($this.data('events')[evt], function(k) { newOrder.push(k); }); if (newOrder.length > pos + 1) { newOrder.splice(pos, 0, newOrder.pop()); var evts = new Object(); $.each(newOrder, function(k) { evts[this] = $this.data('events')[evt][this]; }); $this.data('events')[evt] = evts; } }); }; })(jQuery); (function($) { $.fn.reverseStack = function(namespace, func, pos) { var evt = namespace.split('.').shift(); return this .each(function() { var $this = $(this); $this.bind(namespace, func); var revOrder = new Array(); $.each($this.data('events')[evt], function(k) { revOrder.unshift(k); }); if (revOrder.length > pos + 1) { var evts = new Object(); $.each(revOrder, function(k) { evts[this] = $this.data('events')[evt][this]; }); $this.data('events')[evt] = evts; } }); }; })(jQuery);