Created
July 7, 2014 01:57
-
-
Save davidbalbert/33b4d44cd9da2dff1ae0 to your computer and use it in GitHub Desktop.
A curious case.
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
(def hmm-state (atom {:value "Hmm..."})) | |
(defn hmm [state owner] | |
(reify | |
om/IRender | |
(render [_] | |
(om.dom/textarea #js {:value (:value state) | |
:onChange (fn [e] (.log js/console (.. e -target -value)))})))) | |
(om/root | |
hmm | |
hmm-state | |
{:target (. js/document (getElementById "app"))}) |
This is with Om 0.6.4 and ClojureScript 2268.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Without the onChange handler, you can't change the value of the textarea because the textarea is controlled. This is what I would expect. When you add the onChange handler, you're able to change the value of the textarea even though the onChange handler doesn't update the app state, effectively making the textarea uncontrolled (or at least act like it's uncontrolled). Why is this?