Fork me on GitHub
#reagent
<
2019-03-27
>
jlmr13:03:18

Hi, I’m having trouble with radio buttons. I’m trying to programmatically set a specific radiobox to checked using (set! (.. (js/document.getElementById @external-val) -checked) true). This works fine, but after this happened the :on-change event handlers for these radio buttons are no longer called on subsequent user actions. Am I missing something obvious? Would be great to get some pointers. Thanks!

oconn13:03:08

@jlmr Could you post a little more context? Maybe a the component you’re rendering?

Mno13:03:29

huh I didn’t know you could do this (js/document.getElementById @external-val) I always thought it was (.getElementById js/document @external-val)

Mno13:03:07

yep definitely works, Thanks for sharing, Sorry I’m not experienced enough to see any issues there.

jlmr13:03:54

@hobosarefriends I just copied it from other places, never noticed it was anything special 😉

jlmr13:03:22

@oconn Just noticed something strange. I also have some code to reset all checkboxes to unchecked and the :on-change handlers keep working in that case. I’m trying to figure out what’s different between the two

oconn13:03:22

checked seems to always be set to nil right?

oconn13:03:39

I’d see if removing the when does anything for you

jlmr13:03:24

That fixed it!

jlmr13:03:33

so obvious in hindsight

oconn13:03:10

Awesome! good to hear

tomc22:03:49

Has anyone had any luck integrating reagent with https://www.slatejs.org/? In this example, slate-1 creates a basic contenteditable div that I can click into and make changes, but slate-2 creates a div that I can't even put the cursor in. Any idea what I'm doing wrong?