Skip to content

Instantly share code, notes, and snippets.

@madeingnecca
Last active August 29, 2015 14:10
Show Gist options
  • Save madeingnecca/63732ab6d12082d02684 to your computer and use it in GitHub Desktop.
Save madeingnecca/63732ab6d12082d02684 to your computer and use it in GitHub Desktop.
JS - bindForBusinessEvent
(function(root, name) {
function bind(fn, context) {
// Save original args, but remove the first 2 arguments (fn, context).
var outerArgs = Array.prototype.splice.call(arguments, 2);
return function() {
// Wipe out first argument, which is a "event" object.
var innerArgs = Array.prototype.splice.call(arguments, 1);
return fn.apply(context, innerArgs.concat(outerArgs));
}
}
root[name] = bind;
}(App, 'bindForBusinessEvent'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment