   [text-change-event]
   (-> text-change-event .-target .-value))
 
+(defn pull-single
+  "Same as (safe-get (pull db [attr] eid) attr), i. e. it saves you from typing
+  the extra map lookup and, especially, mistyping the second occurence of ATTR."
+  [db attr eid]
+  (safe-get (d/pull db [attr] eid) attr))
+
 
 ;;;; Event handlers
 

  [[scratch-id scratch-ratom] & attrs]
  {:pre [(even? (count attrs))]}
  (fn [node]
    (let [id (plumbing/safe-get-in node [:attrs :id])
          default-attrs
          [:value (get @scratch-ratom id "")
           :onChange #(rf/dispatch [:set-scratch-val scratch-id id (value %)])]]

(defn search-submitted
  "Send XHR searching for materials."
  [db [scratch-entid]]
  (let [search-string (pull-single db :searchInput scratch-entid)
        url (str "/gq/" (th-utils/url-encode search-string))]
    (when search-string
      (ajax/GET url
