On Tuesday, 20 May 2014 12:06:11 UTC+1, Creighton Kirkendall  wrote:
> I think the best way is to wrap this in a IShouldUpdate check.  Where we 
> check the values against the previous values.  We can do this pretty easily 
> in this case but can't use a template until I finish up wrap.
> 
> 
> (defn handle-change [e data edit-key owner]
>   (om/transact! data edit-key (fn [_] (.. e -target -value))))
> 
> 
> (defn custom-transform [field data owner]
>   (fn [node]
>     (-> node
>         #_(assoc-in [:attrs :value] (om/get-state owner field))
>         (assoc-in [:attrs :onChange] #(handle-change % data field owner)))))
> 
> 
> (defn form-app [data owner]
>   (reify
>     om/IInitState
>     (init-state [_] {})
>     om/IShouldUpdate 
>     (should-update [this next-props next-state]
>        (let [my-vals (select-keys next-props :name address)]
>          (when-not (= next-state my-vals)
>           (om/set-state! my-vals))))
>     om/IRenderState
>     (render-state [_ state]
>       (kioo/component
>        "public/fragments/f1.html" [:#header]
>        {[:input#name]
>         (custom-transform :name data owner)}))))
> 

Hi Creighton

Did you get anywhere with the wraps you mentioned?
I couldn't get your above code to work, it still was causing cursor movement 
when I changed values, so had to remove any setting of :value in the 
custom-transform.

I ended up not needing to have initial values in the form data, which was fine 
as the form being blank to start was ok, but now I've have the need to set 
initial values in the form on first render, and i'm still trying to work out 
how to do this, e.g. {:name "foo"} on entry, then the name field should contain 
the text "foo" but allow normal editing.

-- 
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