Refresh Data on Database
I have successfully created my iphone app except for one last piece. I cant get the data to refresh in the background. I have tried setTimeout() and setInterval(). Both do nothing. I put the setInterval at the bottom of app.js and its like it never get called. I put setTimeout at the end of the function I want called every so often and nothing. I can close the app and open it and the data changes successfully.
Any help is appreciated.
3 Answers
-
Hey Sherman,
setInterval should be the way to go since you want it to occur every x milliseconds vs once in x milliseconds.
Perhaps you're using setInteval incorrectly, or not using setData to update what you see on screen? There isn't any databinding so you'll have to manually update the data used by a tableView.
Hopefully this will get you going:
// create table view var tableview = Titanium.UI.createTableView({ data:data }); setInterval (doSomething, 5000); // runs every 5 seconds function doSomething () { data = []; // do something to update the array data tableView.setData(data); }
-
Hey did you solved this ?
I also have to relaunch the app to refresh the data on the iphone thank you !!! -
No. I ended up just refreshing the whole page every so often. I will get back on this soon and get it to do it the right way.