Created
May 10, 2013 11:45
-
-
Save ChuckJHardy/5553911 to your computer and use it in GitHub Desktop.
Batman.js Flash Messages V1
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
# controllers/dummy_controller.coffee | |
MyApp.flashSuccess "Record updated successfully!" |
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
# my_app.js.coffee | |
@flash: Batman() | |
# When you set an message, it auto-expires | |
@flash.accessor | |
get: (key) -> @[key] | |
set: (key, value) -> | |
@[key] = value | |
if value isnt '' | |
setTimeout => | |
@set(key, '') | |
, 2000 | |
value | |
@flashSuccess: (message) -> @set 'flash.success', message | |
@flashError: (message) -> @set 'flash.error', message |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment