This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-10-26
Channels
- # announcements (17)
- # babashka (68)
- # beginners (8)
- # biff (14)
- # calva (25)
- # cherry (10)
- # clj-kondo (1)
- # clj-on-windows (12)
- # cljsrn (6)
- # clojure (134)
- # clojure-berlin (1)
- # clojure-europe (33)
- # clojure-nl (4)
- # clojure-norway (6)
- # clojure-uk (10)
- # clojurescript (9)
- # datalevin (8)
- # datomic (34)
- # docker (1)
- # emacs (31)
- # fulcro (6)
- # honeysql (8)
- # java (7)
- # joyride (14)
- # kaocha (7)
- # malli (11)
- # nbb (4)
- # off-topic (11)
- # pedestal (14)
- # rdf (53)
- # re-frame (6)
- # reagent (39)
- # reitit (2)
- # releases (9)
- # rewrite-clj (14)
- # shadow-cljs (97)
- # specter (1)
- # testing (5)
- # tools-deps (12)
- # vim (4)
- # xtdb (9)
I have a style/pattern question for you this morning: I have several dropdowns, with data-driven names (ie. not known in advance) and contents - and each is associated with another dropdown, the contents of which should depend on the selection of its 'parent'. I set out to have the hx-target of the parent be the child to be repopulated, but I'm struggling to see how I can interpret the Post correctly; in particular, how to know which dropdown changed without splitting them all into separate forms, or doing some kind of ugly state-tracking, and I ultimately want all of their information to be submitted together. (hmm :thinking_face: can you nest forms; I suppose I should find that out to start with. I'm not a web-front-end-guy (I prefer game engines for UI))
for now I'm just recalculating the contents of all of them on-change 😕
the first thing that comes to mind is, I wonder if you can re-render all of the dropdowns together for simplicity? edit: I see that's what you're doing! if it's fairly straightforward and not computationally expensive to do so, that may not be a bad approach. though I think you can fairly easily have the htmx post include only data from the dropdown you've just changed. E.g. you can put :hx-post directory on the dropdown element, and then there might be a way to tell htmx to not include data from other elements in the form
hmm- it was directly in the dropdown, but I got the whole form in params. I'll read the htmx docs more thoroughly soon, but I'm on to my next headache: xtdb's text-search doesn't support wildcard-first matching :face_with_rolling_eyes:
yeah, finding out if there's a way to filter out the other form values would be the main thing. it looks like :hx-params might do that, except I can't tell for sure because the docs page for it is giving me an internal server error... (https://htmx.org/attributes/hx-params)
haven't done any full-text search mint xtdb myself--but good luck :)
huh, looks like the internal server error is gone now. (maybe I caught it during a deploy or something...)
weird- it loads fine for me, and yes! this looks like what I would need. I kinda hate that i'm recalculating it all; it may get pretty costly, but it's an experiment that might turn into an admin interface of a product. not worth worrying about at the moment 🙂 thanks again! You've been super helpful, and if I ever make a dime from something I build with biff, you'll get a cent or two 🙂
haha excellent! I hope you make many dollars, tens of dollars even
(not a full tithe, but a nice bonus from the first influx) 😉
btw--there is another pattern I've used which may or may not work here. I have a dropdown, and the rest of the form's contents depend on the value of the dropdown. I render all the sections of the form on the initial page load, but only the "active" one is displayed, the rest are hidden. then I just stick a Hyperscript one-liner on the dropdown so that whenever the dropdown changes, the appropriate form section is shown. (the values of the dropdown correspond to the IDs of the sections).
then it's all client side too
I think the Hyperscript is something like show .section in #sections when its id is my value