       (fn [data]
         (log "Received from server:")
         (log-clj data)
-        (mark-completed event))
+        (set-edit-state "edit-completed" event))
       (fn [& args]
-        (jq/add-class $elem "edit-failed")
+        (set-edit-state "edit-failed" event)
         (apply alert-error args)
         ))))
 

  (apply inner args)
  (add-sort-to (first args)))

(defn- mark-in-progress [event]
  (let [$elem ($ (.-target event))]
    (jq/add-class $elem "edit-in-progress")))

(defn- mark-completed [event]
  (let [$elem ($ (.-target event))]
    (jq/add-class $elem "edit-completed")))

(defn- saves-edit [event]
  (.preventDefault event)

  (let [editable-cells ($ :td.editable)]
    (.attr editable-cells "contentEditable" true)
    (.attr (jq/find editable-cells "a") "contentEditable" false)
    (bind editable-cells "click" (juxt expand-editable-text (partial set-edit-state "edit-in-progress")))
    (bind editable-cells :keypress (return-key-pressed saves-edit))))

(defn- create-search-table [parent data]
