Fork me on GitHub
Pablo Fernandez10:08:39

Can a component have more than one top level html element?


@pupeno: A component renderer has to return valid hiccup.

(defn wrong-component
   [[:div "Hello"] [:div name]])     ;; a vec of 2 [:div] 
The above isn't valid Hiccup and you'll get a slightly baffling error. You'll have to correct this mistake by wrapping the two siblings in a parent [:div] see below:
(defn right-component
     [:div "Hello"] 
     [:div name]])     ;; [:div] containing two nested [:divs]

Pablo Fernandez10:08:34

@mikethompson: isn’t it possible in Hiccup to return a list of vectors for that?

Pablo Fernandez10:08:19

I remember finding a way because I didn’t want to have to add a div every time I had an if-expression. But I don’t remember exactly what the solution was, I think it was lists.


I have another weird issue with calling BootstrapValidator from Reagent. This time I want to have the option to retrieve values from the server and "fill them in" from the side, which should trigger revalidation. I use property :value (:myfield @state), and that displays the value in the input field when I set the ratom value. However, I can't get validation to trigger unless I also use jQuery to set the value.


@ulsa: i believe the reason is that reagent does its' renders asynchronously, so when the validation code runs the inputs are still empty


ideally the validation solution would be working with the model data, not the live DOM


not sure of an easy fix for you


well a setTimeout would be easy but hardly pretty


@pupeno having one top level html element is a restriction of react


i'm using jqueryui to implement sortable connected lists and it's giving me trouble by duplicating some items in the dom even though I cancel the sort/drop operation before it's complete and update the state instead...


i wonder whether i should "force update" of the whole sorted list/s in this case?


or maybe anyone here has tackled this problem before and knows how to deal with it?


gadfly361: btw, thanks for the cookbook example! i used it as a starting point..


Np! Let me know if you get your issue resolved :) Do you have a gist?


@antishok: my current workaround is to set the ratom and also the element; it's ugly, but seems to work.


gadfly361: no gist atm..