简体   繁体   English

向下/向上滚动显示白屏

[英]white screen shows while scroll down /up the

We get the data from server 我们从服务器获取数据 第一个图像显示在几秒后向上/向下滚动显示第二个图像 and append list view .our problem is while scroll up/down first it shows white screen then after shows data. 并附加列表视图。我的问题是在向上/向下滚动时首先显示白屏然后显示数据。 while scroll down/up the before coming white screen should remove 向下/向上滚动时,前面的白色屏幕应该删除

for (var i=0; i<len1; i++){
     if (!listCreated) {
         $("#ulcontent").append("<ul id='content' data-role='listview'  data-split-icon='plus' data-split-theme='b' data-inset='true' class='ui-listview ui-listview-inset ui-corner-all ui-shadow'></ul>");  
                  var listCreated = true;
                            $("#ulcontent").trigger("create");
     }
     var geImage=result.rows.item(i).Image;
     var Custimage="";
         if(geImage)
        {
         Custimage=result.rows.item(i).Image;
         }
$('#content').append('<li class="ui-li-static ui-body-inherit ui-li-has-thumb ui-first-child"><img src='+appendurl+append+Custimage+'><p style="white-space: normal;"><b>Location:</b>'+result.rows.item(i).Location+'<br><b> Description:</b>'+ result.rows.item(i).Comments+'</p></a></li>');
}

When we remove images it's not showing any white screen.But we need image Please tell to us what wrong in my code. 当我们删除图像时,它没有显示任何白色屏幕。但是我们需要图像请告诉我们我的代码中有什么问题。

The listCreated variable in the if (!listCreated) statement and the listCreated variable in the var listCreated = true; listCreated在变量if (!listCreated)语句和listCreated在变量var listCreated = true; statement are two different variables, so if (!listCreated) is always going to return false . 语句是两个不同的变量,所以if (!listCreated)总是返回false That means means you're never actually creating the unordered list and then the list items are just getting displayed on the page background. 这意味着您实际上从未实际创建无序列表,然后列表项目才会显示在页面背景上。 So try moving listCreated to the outer scope like this: 所以尝试将listCreated移动到外部范围,如下所示:

var listCreated = false;
for (var i = 0; i < len1; i++) {
    if (!listCreated) {
        $("#ulcontent").append("<ul id='content' data-role='listview'  data-split-icon='plus' data-split-theme='b' data-inset='true' class='ui-listview ui-listview-inset ui-corner-all ui-shadow'></ul>");
        listCreated = true;
        $("#ulcontent").trigger("create");
    }
    var geImage = result.rows.item(i).Image;
    var Custimage = "";
    if (geImage) {
        Custimage = result.rows.item(i).Image;
    }
    $('#content').append('<li class="ui-li-static ui-body-inherit ui-li-has-thumb ui-first-child"><img src=' + appendurl + append + Custimage + '><p style="white-space: normal;"><b>Location:</b>' + result.rows.item(i).Location + '<br><b> Description:</b>' + result.rows.item(i).Comments + '</p></a></li>');
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM