I'm trying to set up some sort of constant event to check if my page has been resized, using the .resize() function in JavaScript. If the page is resized at all, I want it to trigger a refresh of data so that it follows the proportions of the resized page. However, I can't figure out where exactly to incorporate this into OutSystems. I don't think I can simply make it a client action because I have to specify certain instances to call it; I'm looking for a way to constantly check the .resize function so that when it actually occurs, specific logic will run.
Hi Joseph,
You can achieve with JavaScript very easily.
On the OnReady of your screen, add the following JavaScript to add a listener on window resize and trigger a screen action (in m case, the action is called Action and shows a feedback message):
I am sending you a demo OML. You then can implement the logic it makes the most sense for your use case on the action triggered when the window resizes.
Kind Regards,João
Hi, I set something up similar to what you have. The OnReady runs when the page loads, but does not run again after that, even after resizing the screen a bunch. For example in my attached picture, I tried setting a variable to true, but no matter what it stays false. The same occurs if I have it run an action instead; the action doesn't run. I'm not sure what I'm doing wrong.
I showed you a working example but you changed and did something different.
Why don't you call an action and in that action you do update the variable and do the refresh (like in the solution I shared with you)?
I don't know if I undestand clearly.
I added an event listener in the OnReady function to run the on resize event, and checked that it was working. Is that what you want to achieve?
Cheers,
António Pereira
I tried doing this, but I couldn't get the function to run even when I resized the window. It only runs on the page's initial load, not when I resize afterward.