5
Views
2
Comments
how to use JS in outsystems
Question
As subject, I don't known how to get the "id" or "class" of one widget 
2017-01-10 15-48-58
Hélio Dolores
Staff
Hi Zhou,

Welcome to the OutSystems community!

When you name an UI object (e.g. Container) you can reference it on the javascript (jquery) by doing something like this (on an unexcaped expression):

"<script> alert($('#"+ObjectName.Id+"').text());</script>"
- ObjectName.Id will represent the generated runtime id for that object.

You can also add a class in the "Style" attribute of the object and do something like:

"<script> alert($('.MyClassName').text());</script>"

If you are coding the javascript on the block/page javascript you have to pass this Id to the method, or use the class.

I hope it helps.

regards,
HD
2021-04-07 10-08-47
Zhou Shuai
Hélio Dolores wrote:
Hi Zhou,

Welcome to the OutSystems community!

When you name an UI object (e.g. Container) you can reference it on the javascript (jquery) by doing something like this (on an unexcaped expression):

"<script> alert($('#"+ObjectName.Id+"').text());</script>"
- ObjectName.Id will represent the generated runtime id for that object.

You can also add a class in the "Style" attribute of the object and do something like:

"<script> alert($('.MyClassName').text());</script>"

If you are coding the javascript on the block/page javascript you have to pass this Id to the method, or use the class.

I hope it helps.

regards,
HD
 Thanks for your reply,it is very helpful to me.
 
Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.