-
-
Save murindwaz/4716343 to your computer and use it in GitHub Desktop.
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
# All of your views should inherit from the BaseView. As a result you get the | |
# globalEvents functionality for free. The globalEvents hash is similar to that | |
# of the built-in Backbone events hash. It automatically binds event names to | |
# instance methods. | |
# | |
# class TestView extends ModularView | |
# | |
# globalEvents: | |
# "PhoneRang": "answerPhone" | |
# | |
# answerPhone: -> | |
# # phone answering logic | |
# | |
# Also note that the correct value of `this` is passed in. | |
# | |
class ModularView extends Backbone.View | |
delegateEvents: (events) -> | |
super | |
@globalEvents = @globalEvents or {} | |
for event, handler of @globalEvents | |
@options.pubSub.bind event, _.bind @[handler], @ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment