jQuery Mobile的 - > .append()删除CSS? [英] JQuery mobile -> .append() removes CSS?
问题描述
,jQuery Mobile的完整风格消失了......不知道如何解决这一问题?
when appending items to my list, the complete style of jquery mobile is gone... dont know how to fix this?
这是目前的工作:在不追加列表项,所有的款式都很好
This is currently working: when not appending the list-items, all styles are fine.
<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">
...
但是,如果我开始使用读取来自其他地方,所有的款式都走了数据:
But if I start using to read the data from else where, all styles are gone:
$(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(创造)
应做这项工作。
Well, to trigger the automatic style on new elements, using .trigger("create")
should do the job.
请参见:<一href=\"http://stackoverflow.com/questions/6957910/is-it-possible-to-create-element-on-the-fly-with-jquery-mobile\">Is有可能与jQuery Mobile的动态创建的元素?
或<一个href=\"http://jquerymobile.com/demos/1.0b2/#/demos/1.0b2/docs/pages/page-scripting.html\">http://jquerymobile.com/demos/1.0b2/#/demos/1.0b2/docs/pages/page-scripting.html
编辑: $('#leftnav')的ListView('刷新')
是你想找的,而不是创造的东西。
$('#leftnav').listview('refresh')
is the thing your looking for rather than create.
请参见:<一href=\"http://api.jquerymobile.com/listview/#method-refresh\">http://api.jquerymobile.com/listview/#method-refresh
这篇关于jQuery Mobile的 - &GT; .append()删除CSS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!