使用ajax渲染一个局部视图,然后成功显示新数据(工作正常),但是css没有被应用,有什么想法吗?
$.ajax({
url: baseUrl,
type: 'GET',
data: { date: date },
success: function (response) {
$('#schedule').html(response);
},
complete:function() { $('#listId').listview('refresh');
},
});视图
<ul data-role="listview" data-divider-theme="b" data-inset="true" id="listId">
<li data-role="list-divider" role="heading">
@Model.AppointmentDate
</li>
@foreach (var item in Model.Appointments)
{
<li data-theme="c">
<a href="/Schedule/MobileAppointmentEdit/@item.Id" data-transition="slide">
@item.StartTime @item.Name
</a>
</li>
}
</ul>发布于 2013-03-02 19:39:54
您应该在ajax success中刷新ul,而不是ajax complete。这是因为jquery mobile在页面初始化时应用css,用于动态检索的数据。您必须触发事件才能刷新UI。
参考:http://jquerymobile.com/demos//1.2.0/docs/lists/lists-methods.html jQuery手机列表视图
success: function (response) {
$('#schedule').html(response);
$("#schedule ul").listview();
},https://stackoverflow.com/questions/15173934
复制相似问题