jquery - 在 jQuery Mobile 中卡住 li 标签时出现问题

标签 jquery html jquery-ui css jquery-mobile

我使用 Ajax 和 json 以及 jQuery Mobile 动态创建了 ListView ,除 1 个条件外,一切正常。我必须在 ListView 中卡住第一个 Li 标签以显示为标题。我试过 data-position="fixed"但它不适用于 Li 标签。还有其他方法可以在 ListView 中卡住 1st Li 吗?

例子

enter image description here

这是我的代码。

function popupFunc(data, status) {

            var no = JSON.parse(data.d);


            // creating html string
            var PoplistCode = '<ul data-role="listview"  data-inset="true" data-theme="d"  id="customerList">' + '<li id="header" data-role="list-divider" data-position="fixed" data-inset="true" data-theme="a" >Code: &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Name:</li>';

            // running a loop
            $.each(no, function (index, value) {
                PoplistCode += '<li><a href="home.aspx?Batch=' + this.dept + '">'  + this.id + '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'  + this.id + '</a></li>';

            });

             PoplistCode += '</ul>';
//            //appending to the div
             $('#Popvalue').html(PoplistCode);

             $('#Popvalue').addClass("popheight");



//            // refreshing the list to apply styles
             $("#Popvalue").trigger("create");

             $.mobile.hidePageLoadingMsg();

        }

我从 json 对象动态创建 li 标签。我需要卡住第一个包含 id 作为 header 的 li。

最佳答案

试试这个:

将您的第一个 li 元素更改为此 ==> <li data-role="list-divider">Menu</li>

工作示例 HERE - FIDDLE




更新 fiddle :

FIDDLE-DEMO

您需要做的是用 id 和 class 更新您的 javascript,并在您的 .css 文件中添加样式

如果这就是你要找的,请告诉我

关于jquery - 在 jQuery Mobile 中卡住 li 标签时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18181706/

相关文章:

java - Eclipse 中的 Servlet - 放置静态内容的位置

javascript - 向 html 文本区域添加换行符

javascript - 如何避免 "Internet Explorer restricted this webpage from running scripts or ActiveX Controls"消息?

javascript - 自定义按钮上的执行触发器问题 > Apexchat

html - 主页链接到 Wordpress 中的仪表板

javascript - jQuery - 任何时候只显示一个 div

jquery ui datepicker dateFormat 未按预期工作

javascript - 使用 jQuery 显示更多/更少的项目

带拼写检查功能的 jquery 文本区域编辑器

jquery - 修改宽度或高度时动态更新 CSS3 旋转元素的变换原点