Here’s a workaround we’ve started using for preventing loss of data in a community where the session timeout is 15 minutes. it uses the JS setInterval method so that every 13 minutes it tries to save all the models on the page. If it is unable to save (because, for example, no unsaved changes exist), it shows an alert that says you may be logged out soon, and then re-queries all the models on the page. We put this on a master page.
What would be ideal is to know whether or not the session timeout clock is getting close to 15 minutes, basically use setTimeout instead of setInterval, and use clearTimeout whenever any model is saved or refreshed, and restart the setTimeout when any model is saved or refreshed. Any ideas on how to ‘listen’ to any model being saved or re-queried (without having to add a model action to EVERY model on EVERY page) would be much appreciated.
This is still a work in progress, so any suggestions on how to make it better are also appreciated.
(function(skuid){ var $ = skuid.$; $(document.body).one('pageload',function(){ setInterval(function(){ var models = skuid.model.getModelsList(); console.log (models); skuid.model.save(models,{callback: function(result){ if (result.totalsuccess) { console.log(result.insertResults); console.log(result.updateResults); console.log(result.deleteResults); alert("Your work was just auto-saved."); } else { alert("You may be logged out soon. Click OK to refresh the page."); console.log ('nothing saved'); skuid.model.updateData(models); } } }); }, 720000); }); })(skuid);<br>