Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

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.

— asked April 26th 2010 by Sherman Lilly
  • data
  • database
  • refresh
  • setinterval
  • settimeout
  • tableview
0 Comments

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);
    }
    
    — answered April 26th 2010 by Dan Giulvezan
    permalink
    0 Comments
  • Hey did you solved this ?
    I also have to relaunch the app to refresh the data on the iphone thank you !!!

    — answered May 25th 2010 by Nicolo Verrini
    permalink
    0 Comments
  • 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.

    — answered May 25th 2010 by Sherman Lilly
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.