Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ReactJS Component for type ahead
(defn typeahead [data owner]
(reify
om/IInitState
(init-state [_] {:text ""})
om/IRenderState
(render-state [_ {:keys [text]}]
(let [words (:words data)]
(dom/div nil
(dom/h2 nil "Tag")
(dom/input
#js {:type "text"
:ref "text-field"
:value text
:onChange #(change % owner)})
(apply dom/ul nil
(om/build-all item words
{:fn (fn [x]
(if-not (string/blank? text)
(cond-> x
(not (zero? (.indexOf (:word x) text))) (assoc :hidden true))
x))})))))))
(om/root typeahead app-state {:target (.getElementById js/document "app")})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.