Skip to Content (Press Enter)
OutSystems.com
Personal Edition
Community
Support
Training
Training
Online Training
Developer Schools
Boot Camps
Certifications
Tech Talks
Documentation
Documentation
Overview
ODC
O11
Forums
Forge
Get Involved
Get Involved
Jobs
Ideas
Members
Mentorship
User Groups
Platform
Platform
ODC
O11
Search in OutSystems
Log in
Get Started
Back to Forums
J.
MVP
41
Views
3
Comments
Ajax refresh timer of widgets
Question
Is there a way to periodically refresh a widget (webblocks)
if so, how?
João Pedro Abreu
Staff
I'm not sure if this is what you're after, but there's a
setInterval
javascript function that can be used to that effect.
In the following example RefreshBt.Id is the ID of a button that triggers an action with an AJAX refresh for the desired element. Site.RefreshPooling is the refresh interval, in seconds.
<script type='text/javascript'>
function UpdateMessages(id)
{
document.getElementById('" + RefreshBt.Id + "').click();
return false;
}
setInterval('UpdateMessages()', " + Site.Refresh_Pooling*1000 + ");
</script>
<script type='text/javascript'>
function UpdateMessages(id)
{
document.getElementById('" + RefreshBt.Id + "').click();
return false;
}
setInterval('UpdateMessages()', " + Site.Refresh_Pooling*1000 + ");
</script>
"<script type='text/javascript'>
function UpdateMessages(id)
{
document.getElementById('" + RefreshBt.Id + "').click();
return false;
}
setInterval('UpdateMessages()', " + Site.Refresh_Pooling*1000 + ");
</script>"
"<script type='text/javascript'>
function UpdateMessages(id)
{
document.getElementById('" + RefreshBt.Id + "').click();
return false;
}
setInterval('UpdateMessages()', " + Site.Refresh_Pooling*1000 + ");
</script>"
Dror Svartzman
João,
How can i implment javascript in the code? Under Screen's Extended properties\Web screen Javascript?
Dror
Paulo Tavares
Staff
Hi Dror.
What are you trying to do, specifically?
What João said is the way to do it. He uses the code
<script type='text/javascript'>
function UpdateMessages(id)
{
document.getElementById('" + RefreshBt.Id + "').click();
return false;
}
setInterval('UpdateMessages()', " + Site.Refresh_Pooling*1000 + ");
</script>
probably in an unescaped expression (an Expression widget with the Escaped property set to false), from the syntax, where:
- UpdateMessages is the function to be called after each interval;
- Site.Refresh_Pooling is a site property where you set the interval (in seconds) after which the javascript function should be executed;
- RefreshBt.Id is, in this case, the widget's ID, since in his case he wants to click a button every X seconds.
Does this make it clearer for you?
Regards,
Paulo Tavares
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
See the full guidelines
Loading...