     'click .cancel-btn' : 'onReset'
 
   initialize : () ->
-    @model.on 'show', () =>
-      @$el.show()
+    @model.on 'show', @onShow
     @model.on 'hide', () =>
       @$el.hide()
 

    @$el.find('button').click (e) =>
      @renderFromUrl $(e.currentTarget).data('new')


@FormPopup.View.init = (popupModel, url) ->
  popupView = new FormPopup.View

  onClick : (e) ->
    @closePopup() if $(e.target).closest('.simple_form').length is 0

  onShow : () =>
    @$el.show()
    @_updatePosition()

  closePopup : () ->
    @model.destroy()
    @undelegateEvents()
