 
   setBody: ->
     @body.html @itemData.body + "&nbsp;"
-    
+
   moveUp: ->
     $(@el).insertBefore $(@el).prev()
-  
+
   moveDown: ->
     $(@el).insertAfter $(@el).next()
-    
+
   next: ->
     all = $("#app li").toArray()
     index = all.indexOf(@el)
-    if index < all.length - 1 
+    if index < all.length - 1
       index++
     all[index].view
-    
+
   previous: ->
     all = $("#app li").toArray()
     index = all.indexOf(@el)
     if index > 0
       index--
     all[index].view
-    
+
   indent: ->
-    $(@childrenView.el).append @el
-    
+    if $(@el).prev("li").length
+      $($(@el).prev("li")[0].view.childrenView.el).append @el
+
   outdent: ->
     if $(@el).parents("li").length
-      $(@el).insertAfter $(el).parents("li")[0]
-    
+      $(@el).insertAfter $(@el).parents("li")[0]
+
   render: ->
     that = this
     $(@el).html @template(@itemData)

      if prev
        @stopEditing()
        prev.select()
        prev.view.switchToForm()
      false
    else if keyCode == "40"
      next = App.selection().next()
      if next
        @stopEditing()
        next.select()
        next.view.switchToForm()
      false

  render: ->

    keydown: "handleKey"
    "keydown input": "handleInputKey"
    "blur input": "stopEditing"

  initialize: (itemData) ->
    @itemData = itemData

  submit: ->
    @stopEditing()
    App.mainList.view.newItem()
