Skip to content

Instantly share code, notes, and snippets.

@samccone
Created March 22, 2014 22:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samccone/9715240 to your computer and use it in GitHub Desktop.
Save samccone/9715240 to your computer and use it in GitHub Desktop.
closeable
App.module "Behaviors", (Behaviors, App, Backbone, Marionette, $, _) ->
Behaviors.Closeable = Marionette.Behavior.extend
events: ->
"click .close": @view.close
onShow: ->
$(window).on 'keydown', _.bind(@checkClose, @view)
onClose: ->
$(window).off 'keydown', _.bind(@checkClose, @view)
checkClose: (e) ->
@close() if e.keyCode is 27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment