Skip to content

Instantly share code, notes, and snippets.

@alexslade
Created December 27, 2014 17:02
Show Gist options
  • Save alexslade/18cba1d1f6068679b5da to your computer and use it in GitHub Desktop.
Save alexslade/18cba1d1f6068679b5da to your computer and use it in GitHub Desktop.
(defn update-input [val input]
(reset! val (-> input .-target .-value)))
(defn new-contact []
(let [val (r/atom "")]
(fn []
[:div
[:input {:type "text"
:placeholder "Contact Name"
:value @val
:on-change (partial update-input val)}]
[:button {:on-click #(when-let [c (parse-contact @val)]
(add-contact! c)
(reset! val ""))}
"Add"]])))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment