Web block to refresh

Web block to refresh

  

I have created a web block which has a carousel which is fetching data from web api and it is showing trending news(used a preparation for the same).I have to used the web block in a web screen and I want that web block to refresh every 5 sec with latest trending news.

I don't want to refresh the same page every 5 sec but only web block.

How can I achieve that?

Please be elaborate as I am new to outsystems.


Solution

Create a button with a class name "special" (example) and set the visibility to hidden, then define a javascript on your screen like this:

setInterval(function(){
document.querySelector('.special').click();
},5000);

this will click on the button every 5 seconds.

The button should call a screen action that refreshes your web block.


Hope it's clear for you, let me know if you need more help.

KR

Ruben Bonito

Solution

Hi Shubham,


You can do what Ruben wrote. If you want something without JS (that you have to wrote) you can see this component: https://www.outsystems.com/forge/component/2134/auto-refresh-utils/


Best regards,

Ricardo

Hi Ricardo,

That component is still javascript. You just don't need to do it yourself. But thanks to bring that option here is a really nice component.

Regards,

Marcelo

Shubham Agarwal

Could you please mark the answer as a solution if that solves your problem.

Thanks =D

Thanks to everyone