tableview can only see data returned from function on load

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

Hello all, On load my app calls a function called 'getFeed()' which returns two arrays (from a database) and populates two tableviews.

When I fill out a form to insert or update the db the same 'getFeed()' function is called but the tableviews don't update/refresh with the new content.

I'm printing out the length of the array in the 'getFeed()' function and I can see it is incremented when the function is called the second time.

The 'getFeed()' function is included in the parent window. the two tableviews are contained in a View that is added to the parent window.

http://pastie.org/1033074

Thx!

4 Answers

You've got to clear your tableview...

Add something like :

liveFeedTable.setData([]);
somewhere before
liveFeedTable.setData(live_arr);

Thanks Jean-Philippe, I had that in there at one point with no luck but I put it back for sure now...unfortunately it didn't solve my problem. i think it stems from the fact that nothing is making the for loop fire again that builds the tableview to begin with.

I've wrapped the code below in a function so it can be called from anywhere. everything works great except addFeedLive() will not fire. no idea why. it works great the first time and i can alert and see that all the newly updated array is making it all the way to the function, it just won't fire.

you can see the alert right above the p = addFeed(live_data[i],i); and it has all the new data in it as expected but there's an alert inside the addFeed() function that never fires.

i'm at a total loss as to how a function won't fire -- and of course it works great onload. i'll check out the kitchen sink link you sent.

Thx

function setLiveFeed()
{
    live_arr = [];
    var data_length = live_data.length-1;
    for(i=0; i<=data_length;i++)
    {
        Ti.API.info('LOOP: ' + live_data[i].title);
        p = addFeed(live_data[i],i); ----> everything is great until this function won't fire the second time
    } // end for loop
 
    // put live feed content into table row
    liveFeedTable.setData(live_arr);
}
 
wrap.add(liveFeedTable);
 
setLiveFeed();

ok, just did a quick test and when i moved addFeed() into the setLiveFeed() function it worked every time.

gone test further as soon as i can. crazy.

thx!

Your Answer

Think you can help? Login to answer this question!