Skip to content

Instantly share code, notes, and snippets.

@ChuckJHardy
Created May 10, 2013 11:45
Show Gist options
  • Save ChuckJHardy/5553911 to your computer and use it in GitHub Desktop.
Save ChuckJHardy/5553911 to your computer and use it in GitHub Desktop.
Batman.js Flash Messages V1
# controllers/dummy_controller.coffee
MyApp.flashSuccess "Record updated successfully!"
# 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