 
       @$backdrop = $('<div class="modal-backdrop ' + animate + '" />').appendTo(@$body)
 
-      @$element.on 'click.dismiss.bs.modal',
+      @$element.on 'click.dismiss.modal',
         $.proxy (e) ->
           return if e.target != e.currentTarget
-          if @options.backdrop == 'static' then @$element[0].focus.call(@$element[0]) else @hide.call(this)
-        , this
+          if @options.backdrop == 'static' then @$element[0].focus.call(@$element[0]) else @hide.call(@)
+        , @
 
       @$backdrop[0].offsetWidth if doAnimate # force reflow
 


      @enforceFocus()

      e = $.Event('shown.bs.modal', relatedTarget: _relatedTarget)

      if transition
        @$element.find('.modal-dialog') # wait for modal to slide in

    @resetScrollbar()
    @escape()

    $(document).off('focusin.modal')

    @$element.removeClass('in').attr('aria-hidden', true).off('click.dismiss.modal')

    if $.support.transition && @$element.hasClass('fade')
      @$element.one('miceTransitionEnd', $.proxy(@hideModal, @)).emulateTransitionEnd(300)
    else
      @hideModal()


  Modal::enforceFocus = ->
    $(document)
      .off 'focusin.modal' # guard against infinite focus loop
      .on 'focusin.modal',
        $.proxy (e) ->
            @$element.trigger('focus') if @$element[0] != e.target && !@$element.has(e.target).length
        , @


  Modal::escape = ->
    if @isShown && @options.keyboard
      @$element.on 'keyup.dismiss.modal', ($.proxy (e) -> e.which == 27 && @hide()), @
    else if !@isShown
      @$element.off('keyup.dismiss.modal')


  Modal::hideModal = ->
    @$element.hide()
    @backdrop => @$element.trigger('hidden.modal')

  Modal::removeBackdrop = ->
    @$backdrop && @$backdrop.remove()
