This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-12-16
Channels
- # admin-announcements (44)
- # adventofcode (2)
- # avi (1)
- # beginners (22)
- # boot (328)
- # cider (1)
- # cljs-dev (6)
- # cljsrn (29)
- # clojure (164)
- # clojure-chicago (1)
- # clojure-dev (7)
- # clojure-nl (5)
- # clojure-russia (73)
- # clojure-seattle (1)
- # clojure-turkiye (2)
- # clojured (1)
- # clojurescript (98)
- # core-async (6)
- # cursive (26)
- # datomic (9)
- # editors (5)
- # emacs (41)
- # events (3)
- # garden (2)
- # hoplon (125)
- # ldnclj (18)
- # om (178)
- # omnext (8)
- # onyx (5)
- # parinfer (1)
- # proton (5)
- # re-frame (20)
Hi, I've just started learning Clojurescript but I'm stuck on something pretty basic. I have some content in my web page that I have set to hidden using CSS. I want to make it visible based on a user click. I could use a library like Domina for that (I think) but if I wanted to do that using just Cljs how should I go about it? I'm a bit confused with the Cljs/JS interop. I can get the element using (.getElementById js/document "my-element"). And then what? How can I access the style and the display property declared in my CSS?
Btw I got what I wanted from Domina with a single call to set-styles!
. I was thinking I will learn more about how Clojurescript actually works by doing it by hand but maybe its a silly idea
Doing (sort-by val > (frequencies [5 5 1]))
gives me ([5 2] [1 1])
but what is a way to get [5 2]
?
... huh
oh wow that actually did work.
Thanks
@edwthomas: there are several ways to access JS properties
@trancehime: How in hte world did you get the bot to do that?
@rantingbob: there's a slash command. If you type /clj (+1 2)
it will evaluate it.
@rantingbob: I didn't actually do that, someone else did - you can see who requested the eval in the ;; comment
What's the Clojure way when it comes to functions receiving invalid arguments? Return nil? Throw an exception? The functions are part of the API of my core library.
clojure.core functions throw IllegalArgumentExceptions, if some other exception doesn’t bubble up first (e.g., ClassCastException)
Cool thanks.
@polymeris: Thanks! I’ll try that out.
@polymeris: This worked: (set! (.-display (.-style (.getElementById js/document "my-element"))) "block")
. Like with all the minor roadblocks I've experienced in Clojure, once I get some guidance and see something work in the repl, it all makes sense. Thanks!
What's a top level function (defn) , vs just one created with fn?
The former creates a var that resolves to the fn