Auto refresh displayed block data

Would like to see a auto refresh block function so that embedded views which contain changing data such as calendars are updated on a regular basis.
Artur kindly supplied some code so that pages are refreshed on a regular basis but at the block level would work better when the page contains say a calendar and a form to prevent a refresh halfway through completing a form etc

In addition to Auto Refresh option - Have ability to refresh block(s) upon button actions.

Example 1 - A page that has a form block and a list block on same page. When you submit the form it refreshes the block on page to display the data just submitted.

Example 2 - A page that has a list block with a button. Upon click of button, trigger webhook (preferably in background, without opening another page) to change a status, then refresh block so if no longer in view won’t be displayed in block.

1 Like

Hey Dan, can you share a specific block example to check it on real one. It should be possible

Hi Nick! We should be able to do this via custom code snippets. I have your use case in my todos

1 Like

Hi @artur, Do you have a custom code for this case ? Thank you.

Hi Virginie

This is the code we use
Hope this helps

Dan

image

This may work for this use case:
I create a page called ‘refresh’
Added a code block and added the following code to it:

<script>
window.history.back();
</script>

For any form submission or CTA button, that i wish to trigger a page refresh, I set it to open new page ‘refresh’. The new page opens, script runs and takes user back to the page where the button was pressed, all in under a second. Works with list-details pages too.

I created a comments section with an ability to refresh page when new comment was added. The ‘submit comment’ button opened the page ‘refresh’ and that brought the user back to the page where the comment was posted, with updated records. Works like a charm.

3 Likes

You absolute legend!

Hey @vikasvimal,

Thanks for sharing this workaround.

it works! thanks @vikasvimal

2 Likes

hello what about you don’t want to go back to the previous page but reload the current page which you weren’t there before

1 Like

I don’t know if it’s related to your other post concerning Stripe but it would be this

<script>
window.location.reload();
</script>

okay so will this be on the home page?

If it’s related to your use case from the other post, nope, was just a basic answer to your question.

Maybe you can try this one, on homepage header

<script>
setTimeout("location.reload(true);", 5000);
</script>

This should reload the page after 5 seconds (set it to 2000 or 3000 for 2 or 3 seconds)

PS: not 100% sure of my coding skills, This is a basic code, that doesn’t take in consideration the context of your issue. But you can try it, it won’t destroy anything :sweat_smile:

this work, but the reload is still on like, it’s continuously,

On it

Here’s an alternative script to try. Put this script in the Code inside header of the page that you need to be reloaded.

<script>
    const urlParams = new URLSearchParams(location.search);
    const reload = urlParams.get('reload');
    if (reload ==='true') {
        var newLocation = location.href;
        newLocation = newLocation.replace('reload=true', 'reload=false');
        location.replace(newLocation);
    }
</script>

Then, when you need the page to reload, navigate to it with the querystring ?reload=true. So for example if you are sending the user to /, instead send them to /?reload=true.

What will happen is the page will begin to load, it will detect the reload=true, it will change that value to reload=false, and then it will reload the page one time.

Now that David solved this, I would need a small help from you, if possible.

Could you just tell me, by replying here, if the whole process makes everything work? Stripe subscription then redirect to page then reload the page then the user is set as “paid user” for good and everything displays correctly according to his/her new status of paid customer.

It would be of a great help if I could suggest a solution to my client too. And for everyone here.

Thanks in advance !!

the process of detecting the reload=true , and changing that value to reload=false, can timer be set in that midst?