I've asked this question on StackOverflow: 
http://stackoverflow.com/questions/31107633/re-frame-input-on-change-reset-doesnt-change-input-value

I figure it couldn't hurt asking it here:

---
In the code below, I am having trouble with updating the input value when the 
user types something in:

```
(defn measurement-input [{:keys [amount unit path]}]
  (let [amt (atom amount)]
    (fn []
      [:div
       [:input {:type "text"
                :value @amt
                :on-change #(reset! amt (-> % .-target .-value))}]
       [:input {:type "button"
                :value unit}]])))
```

The input value will not change until until I change :value to :defaultValue. I 
am pretty sure the above example closely mirrors Reagent's input example.

---

In the code below, I am trying to do two things when the user updates the input 
value. I'm trying to reset! the input's value as well as dispatch the value to 
an event handler. I've wrapped up both of these function calls in a do call.

Also of note is that in the code below, the user is able to update the value in 
the text field.

```
(defn measurement-input [{:keys [amount unit path]}]
  (let [amt (atom amount)]
    (fn []
      [:div
       [:input {:type "text"
                :value @amt
                :on-change (do #(reset! amt (-> % .-target .-value))
                                (re-frame/dispatch [:update-value @amt]))}]
       [:input {:type "button"
                :value unit}]])))
```

In the javascript console, I get the following error:

```
Uncaught TypeError: Cannot read property 'call' of null  
template.cljs?rel=1435381284083:101 
```

Any help is appreciated!

-- 
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 clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.

Reply via email to