dot*_*huZ 7 css xml jquery append
将项目追加到我的列表时,jquery mobile的完整风格已经消失......不知道如何解决这个问题?
这当前有效:当没有附加列表项时,所有样式都可以.
<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">
...
Run Code Online (Sandbox Code Playgroud)
但是,如果我开始使用从其他地方读取数据,所有样式都消失了:
$(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>'
);
});
}
});
Run Code Online (Sandbox Code Playgroud)
怎么了?
谢谢!
Py.*_*Py. 10
好吧,要触发新元素的自动样式,使用.trigger("create")应该做的工作.
请参阅:是否可以使用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