【发布时间】:2013-08-12 07:38:32
【问题描述】:
我使用 Ajax 和 json 和 jQuery mobile 动态创建了列表视图,除了 1 个条件外,一切正常。我必须冻结列表视图中的第一个 Li 标记以显示为标题。我试过 data-position="fixed" 但它不适用于 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 标签。我需要冻结第一个 li,其中包含 id 作为 header。
【问题讨论】:
-
你不能把标题放在单独的标签
<h1></h1>而不是li吗? -
@TheReader i 在第一个 li 中动态生成更多
- 标记应该是固定的。使用 h1 标签会破坏我的列表视图结构。
标签: jquery html jquery-ui css jquery-mobile