jQueryモバイルでAjaxとjsonを使用してリストビューを動的に作成しましたが、1つの条件を除いてすべて正常に機能します。ヘッダーとして表示するには、リスト ビューで最初の Li タグをフリーズする必要があります。data-position="fixed" を試しましたが、Li タグでは機能しません。リスト ビューで 1 番目の 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 をヘッダーとして含む最初の li をフリーズする必要があります。