Periodically refreshing a page
What is the right way to periodically reload a page? I guess that <META HTTP-EQUIV="refresh" CONTENT="300"> is not the right way because it bypass push.js, right?
Did you tried setInterval, setTimeout funcitons in jQuery?
setInterval(function(){ // Your code goes here }, 3000);
I might be wrong but this seem be refreshing the whole page and thereby bypasses push.js
Why not use AJAX instead of refreshing the entire page?
@cvrebert I could, but I have a working frontend and backend to which I only need to add this feature. I was hoping that you could do a refresh via push that keeps the same behavior as it happens when I click a link.
Just use the setInterval-function and place a manual call to the push-function inside:
PUSH({ url: /* your url */, transition : "fade" });
available transitions: "fade", "slide-in" or "slide-out"
@garee76 This works. Thanks a lot. My only problem now is that I need to cancel the timeout when I navigate out because it keeps refreshing to the same url.
When calling PUSH like this you may want to set the ignorePush property to true so that it doesn't add the refresh to the browser history. Otherwise if the user hits their back button they'd just stay on the same page.