   delete: (e)->
     e?.preventDefault()
     @confirmDelete @resource, =>
-      $(@el).removeClass('neat-editable').addClass('deleted')
+      @$el.removeClass('neat-editable').addClass('deleted')
       
       @model.destroy
         wait: true

    @templateOptions = options.templateOptions ? {}
    @viewPath = @viewPath ? options.viewPath
    @resource = @resource ? window.inflect.singularize(options.resource)
    $(@el).addClass(@resource)
    
    @model.bind 'change', @render, @
    

  afterRender: ->
    @
  
  inEdit: -> @$el.hasClass('editor')
  canEdit: -> @$el.hasClass('neat-editable') and !@inEdit()
  template: -> if @inEdit() then @editTemplate else @showTemplate
  
  cancelEdit: (e)->
    e?.preventDefault()
    e?.stopImmediatePropagation()
    if @inEdit()
      @$el.removeClass('editor').addClass('neat-editable')
      @render()
      @trigger('edit:end')
    @
  
  edit: ->
    unless @inEdit()
      @$el.addClass('editor').removeClass('neat-editable hovered')
      @trigger('edit:begin')
      @render()
      @autofocus()
    @
  
  autofocus: ->
    @$el.find(':input:visible').first().focus()
  
  save: (e)->
    e?.preventDefault()
