Created
October 19, 2012 19:26
-
-
Save tstone/3920178 to your computer and use it in GitHub Desktop.
Jquery on multiple events (untested)
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
// Javascript | |
jQuery.fn.on_original = jQuery.fn.on; | |
jQuery.fn.on = function() { | |
var args = Array.prototype.slice.call(arguments, 0); | |
var events = args[0]; | |
var params = args.slice(1); | |
events.split(' ').forEach(function(ev) { | |
var eventArgs = params.slice(0).unshift(ev); | |
jQuery.fn.on_original.apply(this, eventArgs); | |
}.bind(this)); | |
} | |
# Coffeescript | |
jQuery.fn.on_original = jQuery.fn.on | |
jQuery.fn.on = (args...) -> | |
args[0].split(' ').forEach (ev) => | |
jQuery.fn.on_original.apply this, args.slice(1).unshift(ev) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment