gpt4 book ai didi

JQuery mobile -> .append() 删除 CSS?

转载 作者:数据小太阳 更新时间:2023-10-29 01:47:16 25 4
gpt4 key购买 nike

将元素 append 到我的列表时,jquery mobile 的完整样式消失了...不知道如何解决这个问题?

这目前有效:当不 append 列表项时,所有样式都可以。

<div class="ui-grid-a">
<div class="ui-block-a" id="blockaid">
<ul id="leftnav" data-role="listview" data-theme="g" data-filter="true" >

<li><a href="index.html">
<img src="images/bb.jpg" />
<h3>Firstname Lastname</h3>
<p>123456789</p>
</a></li>
</ul>

</div>

<div class="ui-block-b">
...

但是如果我开始使用从其他地方读取数据,所有样式都消失了:

        $(document).ready(function() {

$.ajax({
url: 'test.xml',
dataType: "xml",
success : parse,
error : function (xhr, ajaxOptions, thrownError){
alert(xhr.status);
alert(thrownError);
}


});

function parse(document){
$(document).find("Details").each(function(){


$("#leftnav").append(


'<li>' + '<a href="#">' + '<img src="images/album-xx.jpg" />' +
'<h3>' + $(this).find('Name').text() + '</h3>' +
'<p>' + $(this).find('Number').text() + '</p>' +
'</a>' + '</li>'
);
});
}
});

怎么了?

谢谢!

最佳答案

好吧,要触发新元素的自动样式,使用 .trigger("create") 应该可以完成这项工作。

参见:Is it possible to create element on the fly with jQuery Mobile?

http://jquerymobile.com/demos/1.0b2/#/demos/1.0b2/docs/pages/page-scripting.html

编辑:$('#leftnav').listview('refresh') 是您寻找而不是创建的东西。

参见:http://api.jquerymobile.com/listview/#method-refresh

关于JQuery mobile -> .append() 删除 CSS?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7226998/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com