我正在使用Sencha Touch构建类似于电子邮件的应用程序,并且将NestedList小部件用于导航面板。


收件箱

邮件1
邮件2
邮件3

发件箱


收件箱中可能有很多邮件,因此我想按需加载,当用户滚动到列表末尾时,它将自动加载下10个项目并将新项目追加到列表中。

我该如何实现?

最佳答案

您可以尝试以下操作:

var loadingItems = false;

var fetchItems = function () {
    //fetch new items to add
    loadingItems = false;
};

//nestedList: reference to the nestedList
//x: new x position
//y: new y position
var scrollListener = function(nestedList, x, y) {
    //set some boundary for where we should start loading data
    var screenBottom = nestedList.getHeight() - OFFSET;

    //if we're within some region near the bottom of the list...
    if((y >= screenBottom) && !loadingItems) {
        loadingItems = true;
        fetchItems();
    }
};
nestedList.addListener("move", scrollListener);

关于javascript - 在Sencha Touch中按需加载NestedList的项目,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/4834708/

10-09 17:34