Created
June 25, 2015 14:02
-
-
Save gentoid/d1f55ea2caa9a4643af9 to your computer and use it in GitHub Desktop.
CoffeeScript + jQuery event handling
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
# 1. trigger events | |
$(document).trigger 'flash:message', { level: 'error', message: 'There was an error' } | |
# 2. catch events in another place | |
$(document) | |
.on 'flash:message', (e, params) => | |
if params.level && params.message | |
@show params.level, params.message # call 'show' method doing something interesting :-) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment