This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-03-28
Channels
- # announcements (3)
- # babashka (36)
- # beginners (77)
- # boot (3)
- # chlorine-clover (10)
- # cider (27)
- # clj-kondo (1)
- # cljs-dev (4)
- # clojure (256)
- # clojure-belgium (1)
- # clojure-europe (9)
- # clojure-uk (18)
- # clojuredesign-podcast (9)
- # clojurescript (54)
- # cryogen (8)
- # cursive (3)
- # data-science (1)
- # datomic (2)
- # duct (31)
- # events (1)
- # exercism (3)
- # fulcro (116)
- # joker (20)
- # kaocha (5)
- # meander (2)
- # nrepl (4)
- # off-topic (10)
- # other-languages (15)
- # re-frame (18)
- # reagent (4)
- # shadow-cljs (44)
- # sql (14)
- # tools-deps (17)
I'm finding that implementing a drop down menu in re-frame is less intuitive than I'd hoped. There's a submit button almost by definition. How would I route a dropdown selection back to my app-db? Should I be using a framework for components like this? As you might imagine, I'm new to front end development, so sorry if this sounds strange.
First, think about this: how would you do it with any other framework, or library, or even vanilla JS?
Yeah, I'm super new at this. I've looked at plain HTML, and I've looked at a ReactJS component tutorial. The part that is tripping me up is that I understand how to implement options, but I don't see conceptually how choosing an option is captured into an action. With a button, you have the :on-click #(dispatch something) pattern, but I don't see any examples of this in a dropdown.
Here's where I'm at: (defn template-listing-dropdown [] [:div#template-listing-dropdown [:form [:fieldset [:legend "Templates"] [:p [:label "Select list"] [:select#myList {:on-change #(dispatch [:add-template-items test-director])} ;; need to find how to access the :option :value [:option {:value "nothing"} ""] [:option {:value test-director} "Test Director"] [:option {:value "nonced"} "Nonced!"] ]]] ] ])
my :on-change works to trigger a dispatch, but I don't know how to access the values in :option :value to go into that dispatch and customize the response.
I feel like there should be a reference somewhere that I'm missing...looking at React tutorials and it makes sense over there, but re-frame handles state differently.
(I think)
#(dispatch […])
is syntactic sugar for (fn [& args] (dispatch […]))
and you can access the first argument in #(dispatch …)
with %
. So %
is the event object
@UP5089ML1 You may be interested to look at re-com for ideas and further explanation
Either that or the TodoMVC
example in the re-frame repository under /examples
If you are dealing with a lot of forms, you might want to look into https://github.com/luciodale/fork