Titanium Community Questions & Answer Archive

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

Add to database a see results on another tab

Hi all

I have created a add to favourites and it pops up a visual saying added to favourites and also adds a badge to the favourites tab. But the tableview is not updated. which is understandable as the table has not reloaded.

How do cause the window to reload to show the added favourite?

thanks in advance.

— asked June 25th 2010 by Mark Pierce
  • database
  • tableview
0 Comments

1 Answer

  • Accepted Answer

    Try taking the logic you use to get the data together when the window is first opened and at the end of your function use setData to make your tableView use that data.

    Then when the user saves the favorite, call that function again and the data in the tableView will be updated.

    Here's a really, really rough version of what it could look like:

    var win = Ti.UI.currentWindow;
    var data;
    
    var tableView = Ti.UI.createTableView();
    
    function getData() {
        data = [];
        // your code to get the data & add it to data var
        tableView.setData(data);
    }
    
    function saveFavorite() {
        // save the users favorite to the database, then call
        // getData to update what the user sees on screen
        getData();
    }
    
    // this calls the function when your window loads so
    // it will start out having data
    getData();
    
    win.add(tableView);
    
    — answered June 25th 2010 by Dan Giulvezan
    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.