Skip to content

Instantly share code, notes, and snippets.

@akmiller78
Created January 6, 2016 15:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akmiller78/e14bb779cb8950405e98 to your computer and use it in GitHub Desktop.
Save akmiller78/e14bb779cb8950405e98 to your computer and use it in GitHub Desktop.
Om.next Form With Local State
(defui AddPerson
Object
(render [this]
(let [{:keys [add-fn]} (om/get-computed this)
clear-fn #(om/update-state! this assoc :first-name "" :last-name "")]
(dom/div nil
(dom/input #js {:type "text"
:placeholder "Firstname"
:value (om/get-state this :first-name)
:onChange #(om/update-state! this assoc :first-name (.. % -target -value))})
(dom/input #js {:type "text"
:placeholder "Lastname"
:value (om/get-state this :last-name)
:onChange #(om/update-state! this assoc :last-name (.. % -target -value))})
(dom/button #js {:onClick #(let [{:keys [first-name last-name]} (om/get-state this)]
(add-fn first-name last-name)
(clear-fn))} "Add")))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment