How to set an Id to a div in v9?

How to set an Id to a div in v9?

  
Hi,

I would like to know how can I set an id to a div, adding the Id as an extended property does not work.

Please look: http://screencast.com/t/gplW0zHNmD

Regards,
Cipriano
Hi Cipriano,

You cannot control the Id's generated by the platform.
Instead you should add a custom attribute "data-id" ("data-" is the html5 prefix recommendation for custom attributes) and use that in your javascript/css needs instead.
Check this post for an example: http://www.outsystems.com/forums/discussion/13554/outsystem-9-is-supporting-selenium-webdriver/#Post49520

Another alternative (mostly used when writing reusable components) is to use the platform id's dinamically in expressions.
Check this post for an example: http://www.outsystems.com/forums/discussion/8129/id-of-element/#Post25123 

Also, as a side note, in some cases it's more usefull to use javascript based on classes than on id's (for example when creating blocks that will be reused multiple times in a page). Tip: in Service Studio the "Style" property of a page widget gets added to the "class" attribute in the generated html.

Regards,
João Rosado
Hi João,
 
Thank you for your reply.
 
I don't remember wich version of OS it was, but I think that I was able to do it like that in the past. (V7 maybe?)
 
I need to set the ID, I have a css file and a couple of javascript scripts that are quite big and were built to use the Id of a few elements, I do not wish to waste time updating all those files when I could simply set the Id on 3 ou 4 divs. I know I can use an expression with escaped content set to no and set the html (I am using it like that now), but its an ugly solution that I would like to avoid....
 
Any other way to do it?
 
Regards,
Cipriano
No other ways around it, the Id's are dynamic and should not be able to be overridden by extended properties. (If in some case that happens you should consider it a bug)

The best way is really to just adjust the javascripts to use a custom attribute or style selector instead of static id's.
If it's only 3 or 4 divs I'm pretty sure it's fast to find their uses in the javascript and a simple find/replace will do the job.

Regards,
João Rosado