Skip to content
Create a gist now

Instantly share code, notes, and snippets.

Add a context param to $.fn.bind()
$('h1').bind('click', function() {
}, console);
$('h2').bind('click', {msg: 'clicked!'}, function(e) {
}, console);
(function($) {
$.fn.oldbind = $.fn.bind;
$.fn.bind = function(type, data, handler, context) {
if (!$.isPlainObject(data)) {
context = handler;
handler = data;
data = {};
if (context) {
handler = $.proxy(handler, context);
this.oldbind(type, data, handler);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.