Created
January 6, 2016 15:44
-
-
Save akmiller78/e14bb779cb8950405e98 to your computer and use it in GitHub Desktop.
Om.next Form With Local State
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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