Reload tableview on focus

You must Login before you can answer or comment on any questions.

Hi.

I am parsing the comments on a post from a FB page in my app in a tableview.

I also have a "Comment" button that opens a new window where the user can write and send the comment to the specific post.

On the Alertdialog that shows "your comment has been sent" i have added a win.close(); eventlistener so that window closes and brings back the first with the tableview with comments.

How can i get my new comment to show up there after the comment window closes?

I guess i should add an eventlistener(focus) With a reload function of some kind or similar to the tableview but i am not sure how to do that.

I need it to work booth for Android and iOS.

Any ideas?

Thanx

1 Answer

Accepted Answer

Hi Rickard Harrysson,

Try to make one function for fill data in table and call that function in window focus event like this. sometime Android does not fire focus event for that you need to fire custom event.

function loadDataInTable() {
    tableView.data = [];
    //======= do your table fill stuff here
}
win.addEventListener('focus', function(t) {
    loadDataInTable();
});
 
Ti.App.addEventListener('loadData', function(eve) {
    loadDataInTable();
});
for android call this in other window.
Ti.App.fireEvent('loadData');
Best luck

— answered 12 months ago by Nitin Chavda
answer permalink
2 Comments
  • Is focus fired when you show a window that was previously hidden ?

    — commented 8 months ago by Dallas Clark

  • Hi Dallas,

    which platform ios or android?.

    — commented 8 months ago by Nitin Chavda

Your Answer

Think you can help? Login to answer this question!