Thank you Leon,

I used your second solution and it works perfectly

2015-03-23 20:48 GMT+02:00 Leon Grapenthin <[email protected]>:

> You can't close over the owner objet of a parent from within a
> subcomponent. That is because there is no guarantee that the subcomponent
> re-renders when the parent owner object is replaced.
>
> One solution would be to pass a callback handler to the subcomponent, e.
> g. have a subcomponent
>
> (fn [{:keys [on-change option]} owner]
>   (reify
>     ...........
>          :onChange (f [e] (let [new-value ...
>                               ...
>                               (on-change new-value)))))
>
> And call (om/update-state! ) within passed on-change. Notice that using
> this approach, when the parent owner changes, the passed on-change fn also
> changes which will lead to your subcomponent being recalculated with it,
> even if option didn't change. Which is what you want.
>
>
> A faster workaround is to not create a subcomponent in the first place.
>
>   om/IRenderState
>   (render-state [this state]
>     (apply dom/span nil
>       (map
>         (fn [option]
>           (dom/label nil option
>                 ....
>                 :onChange (fn [e] ;; happily close over owner here...
>
> ...
>
> Should suffice.
>
> --
> 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/mbgxAsP3mdI/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/clojurescript.
>

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/clojurescript.

Reply via email to