Skip to content

Instantly share code, notes, and snippets.

@sthawali
Forked from pdokas/Example.js
Created April 2, 2013 10:36
Show Gist options
  • Save sthawali/5291341 to your computer and use it in GitHub Desktop.
Save sthawali/5291341 to your computer and use it in GitHub Desktop.
$('h1').bind('click', function() {
this.log('clicked!');
}, console);
$('h2').bind('click', {msg: 'clicked!'}, function(e) {
this.log(e.data.msg);
}, 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);
}
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment