Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

Updating TableView Data on Focus

$
0
0

I've written a small Titanium project to allow myself to play with a little server I set up. So far, the application is loading json data via a RESTful Java server and creating new contacts using the same server. The contacts that are loaded are loaded immediately on page load when the app is first started. This is something I found in an online tutorial that works well enough, but I would like to add an event listener to fire off an update of the tableView's data every time the focus is sent back to the tab page with the tableView of contacts. This way, if you create a new contact then switch back to the tableView of contacts, it will automatically refresh.

So far, I have not even been able to get a log statement from my event listener. Much less actually perform the update to the tableView.

I've tried adding the following listener in a few different places. Could some possibly point out what I'm doing wrong or point me in another direction to accomplish my goal?

Listener

// create all contacts window
var allContactsWindow = Titanium.UI.createWindow({  
    title:'Contacts',
    backgroundColor:'#fff',
    url:'allContacts.js'
});
 
// add listener to update windows on focus
allContactsWindow.addEventListener('focus', function(e) {
    Ti.API.info("Fired focus event.");
   // allContactsWindow.fireEvent('refreshWindow',{});
});
If it's helpful, I've pushed the app up to GitHub in a public repo. Here's the direct link.

Specs:

  • Titanium Studio, build: 3.2.3.201404181442
  • iOS Simulator - iPhone Retina (4-inch 64-bit) / iOS 7.1 (11D167)
  • MacBook Pro, OS X 10.9.3

Viewing all articles
Browse latest Browse all 8068


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>