PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WEBDEV 2024 → [controls] ID attribute value and custom attributes
[controls] ID attribute value and custom attributes
Iniciado por EKoster, 07,abr. 2021 20:06 - 2 respuestas
Miembro registrado
16 mensajes
Publicado el 07,abril 2021 - 20:06
I can't seem to find the way to set the 'ID' attribute of a control you place on a page. I'm looking for setting the 'id' attribute of the html element (e.g. the field) with a specific value. It seems the current value is autogenerated. In extension to this question, I'm seeking how to add custom attributes to the control. Standard you have 'class', 'style', 'id' and so on, but I would like to add custom ones, in a similar way as you add classes to the controls. The use case for this is e.g. testing the application with something like 'jest' or a different test framework. You can use a query selector, but if the code is generated this is not the most efficient way. With a populated 'ID' and custom attributes you can do this directly being sure you have the correct control the fastest way possible.
Publicado el 07,abril 2021 - 21:16
regarding the id, there is an option alowing to remove the automatic name generation for JS. Instead, it's the name of the field as defined in the webdev editor that is used (careful what you use in that case)...

That option is rarely used and is therefore well hidden:
THe option is where you define the html standard (either at the project level or at the page level, in the advanced tab).

Just to the RIGHT of the html option, there is a "..." button. when you clik it, you have extra options, including one called "compress alias and javascript procedure names"

If you uncheck it, you have your control names as designed in the editor.

as for the second part of your question, I'm not sure, but IF it is possible, it's going to be in the advanced tab of the control itself, you can add html code and add values in the class part of the control... Not sure if that will match your request, but you can try
Miembro registrado
16 mensajes
Publicado el 08,abril 2021 - 07:22
Thanks for the reply. I think I can find it. A shame it's so hidden.