269
Views
4
Comments
Solved
Can I assign an Outsystem local variable to an HTML element class as value?
Question

Here's an HTML code:

SyntaxEditor Code Snippet

        <div class='myCustomClass'></div>
 

What I'm trying to do: 

SyntaxEditor Code Snippet

        <div class='"+OutsystemsLocalVariable+"'></div>


The reason I'm doing this is that I want to build an HTML class during runtime and I want it to be dynamic (using innerHTML). 

Is this achievable?

2020-07-21 19-28-50
Rajat Agrawal
Champion
Solution

Hi Anthony,

Yes, it is achievable.

Please refer to below screenshot, try this way and you are able to set your class dynamically in div

 

Hope it will help you.


Thanks,

Rajat Agrawal


2016-04-21 20-09-55
J.
 
MVP

Hi,


Why do you think it's not achievable?

you can do it via expressions or via extended-properties for example



2025-10-09 15-40-22
Craig St Jean
Staff

To J.'s point, with Expressions you would just adjust the escape property.  That said, I would highly encourage you to use extended properties instead to avoid any potential circumstance where the expression could break the HTML.  You simply add an extended property of 'class', and set the value to OutSystemsLocalVariable or such.

2020-07-21 19-28-50
Rajat Agrawal
Champion
Solution

Hi Anthony,

Yes, it is achievable.

Please refer to below screenshot, try this way and you are able to set your class dynamically in div

 

Hope it will help you.


Thanks,

Rajat Agrawal


2018-10-22 02-52-54
Helios

Thanks guys, your suggestions helped a lot. (: 

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