【问题标题】:issue while freezing li tag in jquery mobile在jquery mobile中冻结li标签时出现问题
【发布时间】: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: &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 标签。我需要冻结第一个 li,其中包含 id 作为 header

【问题讨论】:

  • 你不能把标题放在单独的标签&lt;h1&gt;&lt;/h1&gt;而不是li吗?
  • @TheReader i 在第一个 li 中动态生成更多
  • 标记应该是固定的。使用 h1 标签会破坏我的列表视图结构。

标签: jquery html jquery-ui css jquery-mobile


【解决方案1】:

试试这个:

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

工作示例HERE - FIDDLE




更新 FIDDLE:

FIDDLE-DEMO

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

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

【讨论】:

  • @user22332273:对不起,它不起作用。第一个 li 标签不固定。它与其他 li 一起滚动。
  • 你想做什么?修复了第一个元素?并且只滚动其他人?给我一些代码,看看你得到了什么
  • @user22332273:我更新了帖子。请看。我需要单独冻结 id="header" li 标签。
  • @User22332273:当添加更多 li 标签时,标题在你的小提琴中是不可冻结的。 jsfiddle.net/Rajthilak/k9hSB。请指导我
  • 我想我不明白你所说的可冻结是什么意思。你想用这个标题做什么?不可点击?固定位置并滚动视图的内容?解释请理解
猜你喜欢
相关资源
最近更新 更多
热门标签