     (fn search-view-infn []
       (kioo/component "templates/sandbox.html" [:#search-field]
         {[:#searchInput]
-         (bind-and-set-attr kv-area
-                            :onKeyDown
-                            #(when (= (.-key %) "Enter")
-                               (dispatch-kv [:search/submitted kv-area])))
+         (kioo/do->
+           (bind-to-kv-area kv-area)
+           (kioo/set-attr :onKeyDown #(when (= (.-key %) "Enter")
+                                        (dispatch-kv [:search/submitted kv-area]))))
 
          [:#submit]
          (kioo/set-attr :onClick #(dispatch-kv [:search/submitted

           :onClick (fn [e]
                      (.preventDefault e)
                      (dispatch-kv [:add-material/submit kv-area])))
         [:.simple-input] (bind-and-set-attr kv-area)
         [:#tag-list-group] (kioo/substitute [tag-inputs-view])}))))




;;;; Fn for dealing with text input fields

(defn bind-to-kv-area
  "Binds a text input field to the given kv-area in the app-db."
  [[kv-handle kv-ratom]]
  (fn [node]
    (let [id (keyword (plumbing/safe-get-in node [:attrs :id]))
          attrs
          [:value (get @kv-ratom id "")
           :onChange #(rf/dispatch [:kv-area/set kv-handle id (value %)])]]
      ((apply kioo/set-attr attrs) node))))


;;;; Search view
