Created
June 18, 2012 22:03
-
-
Save anonymous/2951001 to your computer and use it in GitHub Desktop.
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
| ## In the function binding the events | |
| _.bindAll(@, callbackName) | |
| callback = @[callbackName] | |
| # Bind callback to this | |
| model.bind(event, callback) | |
| # Store event, to unbind later | |
| evt = [event, model, callback] | |
| @_boundEvents.push(evt) | |
| ## In the function unbinding the events | |
| # iterate through each stored event | |
| for boundEvent in @_boundEvents | |
| # unpack the event, and unbind it | |
| [eventName, eventSource, callback] = boundEvent | |
| eventSource.unbind(eventName, callback) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment