This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-08-04
Channels
- # admin-announcements (33)
- # announcements (2)
- # beginners (10)
- # boot (200)
- # cider (25)
- # cljs-dev (13)
- # clojure (75)
- # clojure-canada (2)
- # clojure-czech (1)
- # clojure-dev (16)
- # clojure-japan (7)
- # clojure-russia (20)
- # clojurescript (206)
- # clr (1)
- # cursive (24)
- # datascript (1)
- # datomic (1)
- # editors (2)
- # hoplon (136)
- # ldnclj (54)
- # off-topic (9)
- # om (5)
- # onyx (8)
- # re-frame (66)
- # reagent (19)
- # yada (21)
Can a component have more than one top level html element?
@pupeno: A component renderer has to return valid hiccup.
(defn wrong-component
[name]
[[: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
[name]
[:div
[:div "Hello"]
[:div name]]) ;; [:div] containing two nested [:divs]
Words taken from: https://github.com/Day8/re-frame/wiki/Creating-Reagent-Components#form-2--a-function-returning-a-function
@mikethompson: isn’t it possible in Hiccup to return a list of vectors for that?
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
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...