Fork me on GitHub
#beginners
<
2023-02-26
>
M J10:02:44

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" value

phill10:02:48

You 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")

👍 2
kennytilton10:02:11

...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")

kennytilton14:02:12

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")

joshcho22:02:58

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.

kennytilton23:02:28

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!

kennytilton23:02:55

Oh, and don't be shy about taking this to the #C6N245JGG channel.

kennytilton23:02:30

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.

kennytilton23:02:17

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?

❤️ 2
joshcho11:02:43

I will take a look at that link

joshcho11:02:48

Also might ask that channel later

kennytilton13:02:28

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.