Forum

Thread tagged as: Question, Discussion

Trigger page refresh on perch region update?

Does anyone know whether it's possible to trigger a page refresh somehow when I change the content of a region?

I have a monitor with an information panel that I'm driving using perch, and have to manually refresh the browser following any content changes.

I know I could do a timed refresh of the page, but I don't want to do that.

So, any of you clever people got any suggestions? :-)

Thanks Chris

Chris George

Chris George 0 points

  • 6 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

There's nothing built in.

You'd have to create an app to listen to API events and then do something based on that. https://docs.grabaperch.com/api/events/

oh that looks interesting. Do I have to create an app, or can I access the api direct from my page?

i'm having trouble rationalising in my head how apps and pages can interact.

I have a static page that contains 1 region. That page is displayed all the time.

I'm assuming I can create a very basic app that registers the event handler, but it's the bit where it then does some sort of refresh of the page that I'm having trouble comprehending.

Can anyone help?

Drew McLellan

Drew McLellan 2638 points
Perch Support

You'd need to have the app listen for the change and note it. Then have your page poll (or open a socket) to a page that returns the app's status to your JavaScript.

Thanks Drew.

I opted for a slightly simpler method in the end. Reloading a php file (containing the perch call) into a div on an interval timer.

Sure it's not that elegant, but it works and updates without flicker (as it's only updating the content of a div).