-1

我正在开发我的第一个 phonegap 应用程序。我正在尝试从 Web 服务器获取一些数据,然后将它们显示在可折叠列表中。但是,我无法将数据添加到动态列表中。此外,列表结构显示在网页中,但我在 android 模拟器上看不到任何内容。我只看到它的黑页。如何解决这些问题?有人可以帮忙吗?先感谢您。

<!DOCTYPE html>
<html>

<head>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.2/jquery.
mobile-1.3.2.min.css">
<script src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
<script src="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js"
></script>
</head>

<body>

jQuery Mobile Collapsibles 

  <div id = "outer" data-role="content"> 

    <div id="list" data-role="collapsible-set"> 

      <div id="first" data-role="collapsible"> 

        <h3>Güvenlik</h3> 

        <p id="guvenlik">I'm the expanded content.</p> 

      </div> 

      <div id="second" data-role="collapsible"> 

        <h3>Sağlık</h3> 

        <p id="saglik">I'm the expanded content.</p> 

      </div> 
      <div id="third" data-role="collapsible"> 

        <h3>Diğer Servisler</h3> 

        <p id="diger">I'm the expanded content.</p> 

      </div> 

      </div> 

<button id="Sorgula">Sorgula</button>
</div>
<script>
$(document).ready(function()
        {
       ...
        });

</script>

</body>
</html>
4

1 回答 1

0

您可以像我一样从列表中插入项目,或者您可以将其写在each函数内部。最后的 find 调用只是在结束时关闭它们。

$.each(list, function(index, value) {   
     $("#container").append('<div  data-role="collapsible" data-iconpos="right" class="ui-collapsible ui-collapsible-inset ui-corner-all ui-collapsible-themed-content ui-collapsible-collapsed ui-first-child ui-last-child">'+
            '<h3 class="ui-collapsible-heading ui-collapsible-heading-collapsed">'+value.name+
            '<ul  data-role="listview">'+some_li_list+'</ul>'+
            '</div>');
    });
$('#container').find('div[data-role=collapsible]').collapsible();
于 2014-12-11T02:52:45.737 回答