Editing Om input properly with a set :value

254 views
Skip to first unread message

Roberto Oliveros

unread,
Jun 4, 2014, 11:33:31 AM6/4/14
to clojur...@googlegroups.com
I need to display an input element with an initial value read from a cursor, but I don't need to update the cursor back when the user enters the new text. For example:


(defn my-comp [app owner]
(reify
om/IRender
(render [_]
(dom/div nil
(dom/label nil "Enter text: ")
(dom/input #js {:value (:text app)
:onChange #()}))))) ;; <- Why do I still need this?


I found that I always have to provide a function to the onChange event in order to let the input element update itself, at least an empty one. Is this the proper way to do this? Many thanks.

Sean Grove

unread,
Jun 4, 2014, 11:44:24 AM6/4/14
to clojur...@googlegroups.com
If you just want the value set initially, and you want the user to be able to change it freely, you can use the :defaultValue attribute instead of :value.



--
Note that posts from new members are moderated - please be patient with your first post.
---
You received this message because you are subscribed to the Google Groups "ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojurescrip...@googlegroups.com.
To post to this group, send email to clojur...@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.

Roberto Oliveros

unread,
Jun 4, 2014, 12:34:28 PM6/4/14
to clojur...@googlegroups.com
That's the proper way, thank you.
Reply all
Reply to author
Forward
0 new messages