Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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);

This comment has been minimized.

Show comment Hide comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment