Here is the code for the component in the dialog:
(defn select-component []
(let [val (atom nil)]
(fn [id choices name-fn value-fn selected-item]
(js/alert (str "Select component " @val " vs " selected-item))
(swap! val #(or % selected-item))
[:div
[:select {:id id
:value @val
:on-change #(reset! val (-> % .-target .-value))}
(for [c choices]
^{:key c}
[option-component (name-fn c) (value-fn c)])]])))
The component needs to do 2 things:
1. Change state when the select is changed (obviously)
2. Reflect the starting value as the selected item when initially rendered
The problem I have is after editing a row where the dialog and select items are correctly populated, editing a second row does not work. The VAL captured by the component closure function already has a value, so the OR expression returns that value, rather than the new one for the new row being edited.
So, is there a way to reset VAL when the component is being rendered with new values?
--
Note that posts from new members are moderated - please be patient with your first post.
---
You received this message because you are subscribed to a topic in the Google Groups "ClojureScript" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/clojurescript/yqDBySfa51Y/unsubscribe.
To unsubscribe from this group and all its topics, 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.