   (let [new-title (.. event -target -value)]
     (om/update! app :title new-title)))
 
+(defn handle-title-blur [event app]
+  (let [new-title (.. event -target -value)]
+    (p/set-document new-title (:input @app))
+    (p/remove-document (:last-title @app))
+    (om/update! app :last-title new-title)
+    (om/update! app :titles (p/get-all-titles))))
+
 (defn title-field [app owner]
   (reify
     om/IRender

      (dom/div #js {:id "title-field"}
        (dom/input #js {:type "text"
                        :onChange #(handle-title-change % app)
                        :value (:title app)})))))

;; Left menu

(defn update-current [event app]
  (let [title (.. event -target -textContent)]
    (om/update! app :input (p/get-document title))
    (om/update! app :title title)
    (om/update! app :last-title title)))

(defn delete-click [title app]
  (p/remove-document title)
