donglinxia1541 2014-12-30 05:40 采纳率: 0%
浏览 42

我想为jQuery的每个命令添加一个滚动和无限滚动

The following code parses an rss feed from XML and displays it as a listview on a php/jquery page. Pretty cool so far with only only issue

 function parseXml(xml)
  {
    $("#main").html("<ul id='content' data-role='listview' data-inset='true'></ul>");

    //make window scrollable after items exceed document height
    $document_height = $(document).height();
    $culminated_height = 0;
    $items_displayed_on_screen = 0;

    $(xml).find("item").each(function()
    {

      $("#content").append("<li><a href='"+$(this).find("date").text()+"'><img src='"+$(this).find("location").text()+"'/><h2>"+$(this).find("report").text()+"</p></a></li>");

      //make scrollable after document height is reached
      $culminated_height  +=  $("li").height();

      $items_displayed_on_screen++;
      if ($culminated_height >= $document_height){



              return false; //break
          }

    });

I cant make this scrollable. So far the $culminated_height and $document_height help me to stop displaying more items when the culminated height exceeds the window/document height. I need this section to be scrollable that does not greatly exceed the window height and further content sort of auto loads as a user goes further down the scroll. I've looked into jquery infinite scrolling techniques but can't seem to make them work with this jQuery each function so far. Any help?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 access多表提取相同字段数据并合并
    • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
    • ¥20 Java-Oj-桌布的计算
    • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
    • ¥20 有人知道这种图怎么画吗?
    • ¥15 pyqt6如何引用qrc文件加载里面的的资源
    • ¥15 安卓JNI项目使用lua上的问题
    • ¥20 RL+GNN解决人员排班问题时梯度消失
    • ¥60 要数控稳压电源测试数据
    • ¥15 能帮我写下这个编程吗