我使用 Ajax 和 json 以及 jQuery Mobile 动态创建了 ListView ,除 1 个条件外,一切正常。我必须在 ListView 中卡住第一个 Li 标签以显示为标题。我试过 data-position="fixed"但它不适用于 Li 标签。还有其他方法可以在 ListView 中卡住 1st Li 吗?
例子
这是我的代码。
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: Name:</li>';
// running a loop
$.each(no, function (index, value) {
PoplistCode += '<li><a href="home.aspx?Batch=' + this.dept + '">' + this.id + ' ' + 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 :
您需要做的是用 id 和 class 更新您的 javascript,并在您的 .css 文件中添加样式
如果这就是你要找的,请告诉我
关于jquery - 在 jQuery Mobile 中卡住 li 标签时出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18181706/