Seth’s approach is very similar … and has the pro/con of a full page reload. A bit jarring, but also guarantees a full new page. My approach would just update the model, and update the page inline. I also think it might only do it once, as setTimeout I think it a single shot whereas setInterval does it over and over again?
Taking from Seth’s example, it would look something like this (also updated to do it once per hour):
(function(skuid){<br /> $(document.body).one("pageload", function(){<br /> var myModel = skuid.model.getModel('ADD_YOUR_MODEL_NAME_HERE');<br /> var waitTime = 60 * 60 * 1000; // 60 minutes time 60 seconds time 1000 milliseconds<br /> setInterval(function() { myModel.updateData();
}, waitTime);<br /> });<br />})(skuid);
I’ll apologize in advance … I didn’t test this code! Fingers crossed… To make this easier to test, change the “waitTime” to something really short like “3000” (instead of 60601000), which will be once every 3 seconds.
I am attempting to auto-refresh a page. I was able to use Seth’s code above and refresh the full page, but I would really like to only refresh the model like you have suggested Chris. However, when I apply your code, everything on the page disappears.
I am choosing ‘Inline’ as the Resource Location and using the following code:
The model in the page include should be the same. The model should still be accessible via the model name (skuid.model.geModel). Side note: If you’re working with page includes, make sure that the model names are unique between the parent page and child page.
How can we include more models in to this script? We have two models on a page (where one is Basic model and aggregate model). How can i refresh both the models automatically?
var model1 = skuid.model.getModel('MyModel1'),<br> model2 = skuid.model.getModel('MyModel2'); // In the setInterval function... skuid.model.updateData([model1,model2]);