Search code examples
tabsfocustitaniumtableviewreload

Titanium: How to reload a tab upon focus?


I have built a favorite-tab in my application that displays entries in a database that are flagged as such. On the backside this works as it should, but I can't figure out how to reload the favorites tab after changes have been made. When I quit and relaunch the app though, the updates appear as they should.

In essence I have the same problem as is presented here: http://developer.appcelerator.com/question/31211/tab---tableview--database-reload

"I have a 'search' and 'search history' tab in my application. Every search executed under this tab gets inserted into my local db. However the new search is not reflected in the tableview retrieving data from the DB in the 'search history' tab when i browse to it, after searching. The latest search, however, gets loaded when I exit the app and relaunch it. I need some help in figuring out how to trigger the tableview reload without exiting the app. SOLUTION UPDATE: I feel 'noobish' for asking this question but it was really so simple I added a 'focus' eventlistener for the window housing the tab to load the data. win.addEventListener('focus', function() { loadDBdata(); });

This seems reasonable, but what should the loadDBdata function should contain? I would greatly appreciate any pointers to this.


Solution

  • i would suggest firing an event when the favorites are updated and having an event listenter on the table that holds the favorites list. When it receives the event, it should update the tables contents.

    see this question I just answered it should provide a guide for solving your problem also

    Problems with refresh function for page, in Appcelerator