1416
Views
11
Comments
Solved
Expression Escape Content in Reactive Web
Question

Is there an alternative to 'Escape Content' on an expression in a Reactive Web application? If not, are there plans to add it? 

Yes, I know I can (and should) use widgets to build the UI, but in certain cases I may want/need to build an HTML expression.

Staff
Rank: #20
Solution

Just an update just to let everyone know that there is a Forge component for this that will allow you to stay away from having custom JavaScript directly in your apps (which is always a good practice):

Cheers,
Tiago Simões

mvp_badge
MVP
Rank: #6

Hello Joseph, 

I didn't took a deep look into reactive, but as ut and mobile uses the same programming model, I would say you can use the HTML widget in the screen. 

It exists in mobile and should exists in Reactive Web apps as well... 

Cheers 

Staff
Rank: #20

Hi Joseph,

You will need to use a JavaScript node to set the innerHTML of some widget.

Cheers,

Tiago Simões

mvp_badge
MVP
Rank: #6

Hello Tiago,

Can't use the HTML element?

mvp_badge
MVP
Rank: #6

OK, I see.

With the HTML element, you will need to build every part of the HTML piece of code using the canvas (with potentially other HTML elements), while using JavaScript you can just "write" your HTML and inject it...

I would like to have the "unescaped" expression... Neither available way is good...

Cheers

Staff
Rank: #20

Hi Eduardo,

You can encapsulate the JavaScript above in a block (as shown in the screenshot) and use it as a widget. 

Cheers,

Tiago Simões 

PS: be sure to sanitize the HTML content, so users are not allowed to inject arbitrary JS in your app. 

Staff
Rank: #20

2 more things:

- the HTML element is static so that Service Studio knows how to render it, and is useful to create UI components.

- it may go without saying, but it’s a good practice to centralize generalist blocks with custom JavaScript and HTML in libraries, so it’s easier to maintain. The less JS you have on your app, the easier it will be to change it in the future. 

Rank: #7487

Thanks guys. Yes, I was aware of the HTML widget, but as you indicated, I would have to chain them together so it won't work for my purpose. The javascript option worked perfectly, though (I marked it as the solution).

Rank: #92

I've found it works better if on the OnParametersChange event as at onReady the input may not have the value.


Staff
Rank: #20
Solution

Just an update just to let everyone know that there is a Forge component for this that will allow you to stay away from having custom JavaScript directly in your apps (which is always a good practice):

Cheers,
Tiago Simões