Problems with refresh function for page, in Appcelerator

前端 未结 2 1636
南旧
南旧 2021-01-14 17:21

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 t

相关标签:
2条回答
  • 2021-01-14 17:42

    this is a common 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);
    )();
    
    0 讨论(0)
  • 2021-01-14 17:53

    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);

    0 讨论(0)
提交回复
热议问题