This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-02-26
Channels
- # announcements (1)
- # babashka (6)
- # beginners (12)
- # biff (39)
- # calva (4)
- # cider (5)
- # clj-commons (1)
- # clj-yaml (9)
- # clojure (42)
- # clojure-conj (1)
- # clojure-europe (8)
- # clojurescript-ios (1)
- # clr (1)
- # conjure (7)
- # data-science (1)
- # datalevin (9)
- # emacs (3)
- # helix (1)
- # honeysql (11)
- # hyperfiddle (60)
- # introduce-yourself (1)
- # lsp (26)
- # music (1)
- # off-topic (1)
- # pathom (2)
- # polylith (3)
- # releases (1)
- # sci (1)
- # scittle (21)
- # shadow-cljs (57)
- # spacemacs (3)
- # xtdb (38)
How can I get the element by id of a div element, for example, I have:
<div aria-hidden="false">
<div id="id-10822"></div>
</div>
I would like to getElementById of the "id-10822", then gets its parents "aria-hidden" valueYou may use whichever of the browser's built-in functions you would use in Javascript. Remember the getElementById is a function on the DOM Document, which in ClojureScript can be referenced as js/document
. So you can start with (.getElementById js/document "id-10822")
...and as a lucky CLJS user, you can also use https://google.github.io/closure-library/api/goog.dom.html :
(goog.dom/getElement "id-10822")
Oops. Missed the rest of the Q. Once you have the div, this gives you the parent:
(.-parentNode div) or (goog.dom/getParentElement div)
Once you have the parent, this gives you "aria-hidden":
(.-ariaHidden parent) or (goog.object/get parent "ariaHidden")
I have a CLJ (lein) and CLJS (shadow) project. I kept them separate repositories until now, then yesterday merged them into one repo. One issue I have been having is with CIDER, where I cannot connect to both at the same time. I assume this is because I am using different build tools; are there any good resources on converting a lein project into shadow project? I assume project.clj has to be converted to shadow-cljs.edn, but not sure how.
I feel your pain, been through this myself. I wish had the deets fresh, but what worked for me was following the shadow-cljs instructions for building a project from scratch, but adding the same elements to my lein project. I will see if I can recover what I did...and it might have been the other way around!
Oh, and don't be shy about taking this to the #C6N245JGG channel.
btw, if you do not mind a one-way conversion, I have been known to start from a starter project under a new build tool and just copy my source in.
OK, not finding the lein->shadow steps I was thinking of. Must have gone shadow->figwheel. Have you looked at https://shadow-cljs.github.io/docs/UsersGuide.html#config?
To me the shadow doc is great but not quite direct enough for me to follow, but someone in #C6N245JGG may be able to point you to some step-by-step doc. And don't forget my brute force 🙂 solution: find a shadow starter project and copy your source into that.