Javascript in web block property

Javascript in web block property

  

Hi,


I would like to know how to link a session variable to the javascript present in the web block property. 

could you please help me on this issue.


Regards,

Ekadeep.K

Kuruma Ekadeep wrote:

Hi,


I would like to know how to link a session variable to the javascript present in the web block property. 

could you please help me on this issue.


Regards,

Ekadeep.K

In Outsystems you have an access to the session and site properties. I did not get your questions very well but I will give you an example and hopefully will clarify something for you on how to use it.

Let's say you have a page and you want to alert the user after the document is loaded.

1) Add an expression to the page.

2) Change the "Escape Content" property of the expression you added to "NO".

3) Add the following to the "value" property

"<script type='text/javascript'>
    $(document).ready(function(){
        alert('"+Session.abc+"');
    });
</script>"

Best Regards,

Amit Verma

Amit Verma wrote:

Kuruma Ekadeep wrote:

Hi,


I would like to know how to link a session variable to the javascript present in the web block property. 

could you please help me on this issue.


Regards,

Ekadeep.K

In Outsystems you have an access to the session and site properties. I did not get your questions very well but I will give you an example and hopefully will clarify something for you on how to use it.

Let's say you have a page and you want to alert the user after the document is loaded.

1) Add an expression to the page.

2) Change the "Escape Content" property of the expression you added to "NO".

3) Add the following to the "value" property

"<script type='text/javascript'>
    $(document).ready(function(){
        alert('"+Session.abc+"');
    });
</script>"

Best Regards,

Amit Verma


Thanks for responding , yes i too know that we can access variables through expression and run javascript , but here my code is in web blocks property java script. please refer screen shot . My problem is there is a button built with the javascript and css , i have to link this button to a screen action either directly or by link.Please help me.

Hi Kuruma,

First, creating buttons purely by JavaScript is very likely not the best way to go about using the OutSystems Platform. If at all possible, I'd use a standard Button and style it with CSS and/or use JavaScript to alter it, but keep it a Button so that you can call a Screen Action without hassle.

If however that's really not possible, the only thing you can do to call a Screen Action is to create another Button or Link and hide it, and click that Button or Link from the JavaScript code that is triggered when clicking your own button.

Kilian Hekhuis wrote:

Hi Kuruma,

First, creating buttons purely by JavaScript is very likely not the best way to go about using the OutSystems Platform. If at all possible, I'd use a standard Button and style it with CSS and/or use JavaScript to alter it, but keep it a Button so that you can call a Screen Action without hassle.

If however that's really not possible, the only thing you can do to call a Screen Action is to create another Button or Link and hide it, and click that Button or Link from the JavaScript code that is triggered when clicking your own button.


Thanks Kilian Hekhuis , but actually i'm using a forge component i.e intro.js, which is completely built using javascript and css, I would like to change in that code as per my requirement, where i'm coming across the button which is built in JS. So please suggest me how to link a button in javascript(present in web block property) to screen actions.


I already did. The only thing you can do is have a (hidden) Button or Link, and click it from JavaScript. Just curious, what Forge Component are you talking about?

Kilian Hekhuis wrote:

I already did. The only thing you can do is have a (hidden) Button or Link, and click it from JavaScript. Just curious, what Forge Component are you talking about?

That's nice to hear, could you please send me a demo functionality by .oml file? and the Forge Component is Intro.Js.


Hi Kuruma,

There's not Forge component called "Intro.Js" that is revealed in a search. Can you link to it?

As for a demo, I'm not very well versed in JavaScript, so I can't create such a demo unfortunately. But the idea is simple: add a Button or Link Widget in Service Studio and hide it (use an Extended Property "style" with value "display:none"), and use a JavaScript .click() to click it.

Kilian Hekhuis wrote:

Hi Kuruma,

There's not Forge component called "Intro.Js" that is revealed in a search. Can you link to it?

As for a demo, I'm not very well versed in JavaScript, so I can't create such a demo unfortunately. But the idea is simple: add a Button or Link Widget in Service Studio and hide it (use an Extended Property "style" with value "display:none"), and use a JavaScript .click() to click it.


Please refer the following....https://www.outsystems.com/forge/390/

Thanks. No idea why the search didn't turn this up...