29
Views
4
Comments
Solved
Issue with attritbutes of radiobuttons
Question
Application Type
Reactive

Hello,

I have a need to create a data attribute for all my inputs, however for radiobuttons that attribute is associated with div created by the radiobutton itself instead of being associated with the actual radiobutton. Im sharing some images to help understanding. 

Anyone know how to solve that?

Thanks!

2023-02-13 15-34-45
BabyBear
Solution

If you do not find anything more native. 

An approach I suggest is you can add dynamic class on every radiobutton and use that as the selector and add the attribute using JS 


something like this 


2023-02-13 15-34-45
BabyBear

Hi I think it's because it is an Outsystems widget. But maybe you can add the attribute using javascript? on the onready event of the screen/block


https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_element_setattribute1

You can check this example to add an attribute to the specific html element


UserImage.jpg
Ruben Magalhães

@BabyBear thank you for you answer. 

The problem here is that the radiobuttons are created dynamicly. 

However i was thinking on similar approach using javascript, but try to move the attribute from the parent to child element.

The reason for posting here was to find a more native way of doing it :p

2023-02-13 15-34-45
BabyBear
Solution

If you do not find anything more native. 

An approach I suggest is you can add dynamic class on every radiobutton and use that as the selector and add the attribute using JS 


something like this 


UserImage.jpg
Ruben Magalhães

Yup, that is the approach i am trying right now, because that way the class is on the actual radiobutton.


Thank you!

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.