                           :ref "search"
                           :onChange
                           #(handle-search-change % owner state)})
-          (dom/button #js {:onClick #(search owner opts)} "Search")
+          (dom/button #js {:onClick #(search owner event-chan)} "Search")
 
           (apply dom/ul #js {:id "items-list"}
                  (map (fn [item]

            (dom/button
             #js {:id "add-item"
                  :className "button"
                  :onClick (fn [e] (put! navigate :new))}
             "Add")

            (dom/button
             #js {:id "search-item"
                  :className "button"
                  :onClick (fn [e] (put! navigate :search))}
             "Search"))
          
          (dom/div nil
            (case (first (:route app))
              :add-item (om/build item-add-view (:current-item app) opts)
              :search-item (om/build search-view (:items app)  opts)
              :view-item (om/build item-view (:current-item app) opts))))))))

(util/edn-xhr

;; =============================================================================
;; Helpers

(defn add-item [item owner event-chan]
  (let [new-text (-> (om/get-node owner "new-item-text")
                     .-value)
        new-title (-> (om/get-node owner "new-item-title")
                      .-value)]
    (when (and new-title new-text)
      (put! event-chan {:op :create
                        :data {:item/title new-title :item/text new-text}}))))

(defn handle-item-text-change [e owner {:keys [text]}]
  (let [value (.. e -target -value)
