Created
July 30, 2011 15:56
-
-
Save thegrubbsian/1115668 to your computer and use it in GitHub Desktop.
Backbone.js Proxy Event Method
This file contains 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
Backbone.View.prototype.proxy = function(source, eventName, options) { | |
if (!options) { options = {}; } | |
var self = this; | |
source.bind(eventName, function(args) { | |
var name = options["proxyName"] || eventName; | |
var newArgs = options["proxyArgs"] ? _.combine(args, options["proxyArgs"]) : args; | |
self.trigger(name, newArgs); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment