javascript - Problems with refresh function for page, in Appcelerator - Stack Overflow

Titanium SDK version: 1.6.1iPhone SDK version: 4.2I am using JavaScript.I am developing an app that is

Titanium SDK version: 1.6.1 iPhone SDK version: 4.2

I am using JavaScript.

I am developing an app that is fetching information from an API. In this app, on this page, I got two ways of "refreshing" the content. When the window is focused and when I tap the refresh button.

The problem is every time I do a fresh of the page there is a "copy" of the content under the new content. It is like the app just keeps layering on new copies of the content on top of the others on each fresh.

What am I doing wrong in my code? Is there a way to "clear" the page before each refresh. I can imaging that this issue eats a lot of memory.

You can find my code for the page here:

Titanium SDK version: 1.6.1 iPhone SDK version: 4.2

I am using JavaScript.

I am developing an app that is fetching information from an API. In this app, on this page, I got two ways of "refreshing" the content. When the window is focused and when I tap the refresh button.

The problem is every time I do a fresh of the page there is a "copy" of the content under the new content. It is like the app just keeps layering on new copies of the content on top of the others on each fresh.

What am I doing wrong in my code? Is there a way to "clear" the page before each refresh. I can imaging that this issue eats a lot of memory.

You can find my code for the page here: http://pastie/1778830

Share Improve this question edited Nov 25, 2011 at 2:50 Brock Adams 93.7k23 gold badges241 silver badges305 bronze badges asked Apr 10, 2011 at 13:45 Jonathan ClarkJonathan Clark 20.6k29 gold badges116 silver badges177 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 9

this is a mon architectural problem, you should separate out the function of creating the table and loading the table's data.

you create the table once when the window is created, and you load the data in the table multiple times. Pseudo code below should give you the basic idea.

var win = Ti.Ui.currentWindow;
(function(){
   var table;

   // create the table
   function initializeWindow() {
   }

   // load the data, and update table
   function loadWindowData() {
   }

   initializeWindow();
   loadWindowData();

   // called whenever you want to update window data.
   Ti.App.addEventListener('app:refreshTable',loadWindowData);
)();

TableView -

table.setData([]); // First Clear

table.setData(tableData); // Updated Content

ListView -

listView.sections[0].setItems([]);//First Clear

listView.sections[0].setItems(tableData); // Updated Content

For Updating Content inside Window you can use "open" listener.

win.addEventListener("open",loadData);

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744060405a4551679.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信