admin 管理员组文章数量: 1086019
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 badges2 Answers
Reset to default 9this 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);
本文标签: javascriptProblems with refresh function for page in AppceleratorStack Overflow
版权声明:本文标题:javascript - Problems with refresh function for page, in Appcelerator - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://roclinux.cn/p/1744060406a2526623.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论