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.
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);