Skip to content

Instantly share code, notes, and snippets.

Created June 18, 2012 22:03
Show Gist options
  • Select an option

  • Save anonymous/2951001 to your computer and use it in GitHub Desktop.

Select an option

Save anonymous/2951001 to your computer and use it in GitHub Desktop.
## 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