Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save fearphage/6138049 to your computer and use it in GitHub Desktop.
Save fearphage/6138049 to your computer and use it in GitHub Desktop.
(function(slice) {
var proxy = function(source, eventName) {
var _self = this;
source.on(eventName, function(evt) {
_self.trigger.apply(_self, slice.call(arguments).splice(0, 1, eventName));
});
};
Backbone.View.prototype.proxyEvent =
Backbone.Model.prototype.proxyEvent =
Backbone.Collection.prototype.proxyEvent =
Backbone.Router.prototype.proxyEvent = proxy;
var forward = function(target, eventName) {
this.on(eventName, function(evt) {
target.trigger.apply(target, slice.call(arguments).splice(0, 1, eventName));
});
};
Backbone.View.prototype.forwardEvent =
Backbone.Model.prototype.forwardEvent =
Backbone.Collection.prototype.forwardEvent =
Backbone.Router.prototype.forwardEvent = forward;
})([].slice);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment