is there a way for javascript to tell when a table has timed out and the table needs to be reloaded?
is there a way for javascript to tell when a table has timed out and the table needs to be reloaded?
pmarks906d
Posts: 61Questions: 18Answers: 0
- I have an embedded cloudtable on my web page which I access and control using client side javascript.
- When the table times out it closes the display and visually indicates the page needs to be reloaded.
- I assume when this happens that the javascript cannot access the table until it is re-loaded. Is that assumption correct?
- Is there any way for javascript, through events and/or through polling, to tell when a timeout has happened and that the table needs reloaded?
- Also, when the table has timed out, does the whole page have to be reloaded (location.reload(true)) or is there a way for javascript to cause the table to reload without reloading the whole page?
- If the table reloads without reloading the whole page, do the document.addEventListener('ct-ready' ) and table.on( 'init.dt') events fire again just like when the whole page is reloaded?
Thanks
This question has accepted answers - jump to:
Answers
That is the intention, yes. The idea is that the allowed session time has been timed out, so a new token is required. A refresh is necessitated for that.
Not as an API, but I guess you could poll for the element that shows the time out message and reload if that appears.
A full reload at the moment (this is specific to CloudTable's security mechanism - it isn't a DataTables requirement).
Yes, since it is a page load, the page load events will trigger again.
Allan
Under what conditions does a table session expire? After a certain amount of time? Does the page have to be showing? not showing? closed? I'm trying to set it up so that if i come back to use one of my pages and if the table has expired then my javascript software can reload the page automatically. But I have to know how to get the table to expire to write and test the javascript.
20 minutes non-usage by default.
Allan
When a table has expired and needs reloading, is there a javascript call I can make on the table or its editor, some response from which will indicate that the table needs reloading? I've tried reading from a row but that doesn't fail. I tried submitting a row but I don't know what kind of object the submit() returns, and the submitcomplete event doesn't fire. Thanks.
SOLVED AGAIN: An embedded cloudtable is expired when it has had no connection with the server for a default of 20 minutes. The server closes the connection. So if the browser is closed and then re-opened after 20 minutes, the cloudtable will have to be re-loaded by reloading the page in order to bring the connection current. When the cloudtable is expired, the document on the client side is shown to have a div element with the class name "cloudtables__error-foreground". When the cloudtable is active this div element is not there. So if javascript is able to get a div element by that class name, then the table is expired, and location.reload(true) will have to be called to bring the connection current. Thus the following code works:
That looks like a good way of doing it. Thanks for sharing that.
When I loop back to go on with some more intensive CloudTables development I'll look at putting in an event for that.
Allan