     this
 
   close: ->
-    $(window).off 'keyup', @escape
-    $(window).off 'resize', @resize
+    @$window.off 'keyup', @escape
+    @$window.off 'resize', @resize
 
     mediator.off null, null, this
 

    'click .modal-close': 'close'
    'click .modal-dialog': '_intercept'

  initialize: (options={}) ->
    { @width } = _.defaults options, { width: '400px' }

    @templateData ||= {}

    @resize = _.debounce @updatePosition, 100

    $(window).on 'keyup', @escape
    $(window).on 'resize', @resize

    mediator.on 'modal:close', @close, this
    mediator.on 'modal:opened', @updatePosition, this


  updatePosition: =>
    @$dialog.css
      top:  ((@$window.height() - @$dialog.height()) / 2) + 'px'
      left: ((@$window.width() - @$dialog.width()) / 2) + 'px'

  # Fade out body,
  # re-render the (presumably changed) template,
