Thanks to both you and Dave. I will have to experiment a bit more.
On Monday, October 6, 2014 9:05:57 PM UTC+2, Peter Jaros wrote: > I’ve used a variation on Dave’s solution for a similar problem: I have the > parent component (in this case, elements) set :selected true on the map > representing the selected one before passing those maps to build-all. > > Also, I store which element is selected (actually, an id representing which > is selected) in the app state atom, in a top-level key. Storing it in the > state, as Dave does, works just as well. > > Peter > > > > > On Sun, Oct 5, 2014 at 5:13 AM, Dave Della Costa <[email protected]> wrote: > Hi Andreas, > > > > Seems like it will be hard to do this without passing a channel around, > > but I don't think it's that clunky. Here is one approach: > > > > https://github.com/ddellacosta/om-cookbook/blob/master/complex-selection/src/core.cljs > > > > (You can get that going by cloning that repo and running lein cljsbuild > > once complex-selection from the repo root, and loading up the index.html > > file from that code example's directory.) > > > > I'm not sure if it is exactly what you need--if you submit a full > > example or provide the code you already have (always good practice when > > asking questions on the list), it may be easier to give you some more > > useful suggestions. > > > > DD > > > > > > (2014/10/05 2:44), Andreas Liljeqvist wrote: > > > Say that I want to model a table of things. Something like this: > > > [{:elements [1 2 3]} > > > {:elements [4 5 6]}] > > > > > > I want to select elements by :onClick. > > > Whenever I select an element, all other elements should become deselected. > > > Also I want to display some info about the selected element in a > > grandparent. > > > > > > How would this be best accomplished? > > > For selecting I just do something like (fn [_] (om/set-state! owner > > :selected true) > > > > > > I have got four levels of om-functions > > > > > > element-view > > > > > > row-view > > > > > > table-view selected-view > > > > > > root > > > > > > I could pass a channel from the root, but it feels clunky to pass it > > through several levels when it only going to be used in element-view and > > selected-view. > > > > > > > -- > > 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. > > > > > > -- > Visuals: http://youtube.com/peeja > Words: http://blog.peeja.com/ > Conversation: (603) 548-1203 -- 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.
