尽管referesh,jQuery格式化不适用于ajax数据
I am loading a list view inside a collapsible from the server (php file) via a GET response message. However, jQuery formatting is not being applied to the added HTML despite refreshing the jQuery element
我正在通过GET响应消息从服务器(php文件)加载可折叠的列表视图。但是,尽管刷新了jQuery元素,但jQuery格式化并未应用于添加的HTML
My page is here : http://i.cs.hku.hk/~hsbashir/Project_Work/events/events.html
我的页面在这里:http://i.cs.hku.hk/~hsbashir/Project_Work/events/events.html
HTML Code (relevant code only)
HTML代码(仅限相关代码)
<script>
lastRecord=0;
function loadEvents(){
$('#sample').html( 'hello' );
$.get(
"eventquery.php?lastRecord="+lastRecord,
function( data ) {
$('#loadCollapsible').append( data )
.listview( 'refresh' );
});
}
</script>
</head>
<body style="background-color : #e9e9e9;" onload="loadEvents()">
<div data-iconpos="none" data-role="collapsibleset" data-theme="a" data-content-theme="a">
<div data-role="collapsible" data-collapsed="false">
<h2><img src="today_calendar.png" style="height: 60px; vertical-align:middle;"> Today's Events </h2>
<div id="loadCollapsible">
<!-- Load from php -->
</div>
</div>
PHP Code (relevant code only)
PHP代码(仅限相关代码)
while ($row = mysql_fetch_array($result)){
print '<div data-role="collapsible" data-collapsed="false">';
print '<h5>'.$row['Title'].'<h5>';
print ' <ul data-role="listview">';
print '<li><a href="#">';
print '<table><tr><td>Date</td>';
print '<td style="padding: 10px;">'.$row['Date'].'</td>';
print '</tr><tr>';
print '<td> Time </td>';
print '<td style="padding: 10px;">'.$row['Time_Duration'].'</td>';
print '</tr><tr>';
print '<td> Venue </td>';
print '<td style="padding: 10px;">'.$row['Venue'].'</td>';
print '</tr></table></a></li>';
print '<li style="background-color: #CADECC;">';
print '<button class="ui-btn ui-shadow ui-corner-all ui-btn-icon-left ui-icon-calendar" style="width: 170px; float: right; position: relative;">Add to calendar</button>';
print '</li></ul>';
print '</div>';
}
2 个解决方案
#1
1
jQuery Mobile listview must first be initialized before calling the refresh method.
首先必须在调用refresh方法之前初始化jQuery Mobile listview。
Because you're loading the list with ajax it doesn't get initialized automatically. Try this:
因为您正在使用ajax加载列表,所以它不会自动初始化。试试这个:
function loadEvents(){
$('#sample').html( 'hello' );
$.get(
"eventquery.php?lastRecord="+lastRecord,
function( data ) {
$('#loadCollapsible').append( data );
$('#loadCollapsible ul').listview().listview( 'refresh' );
});
}
更多相关文章
- Server.Htmlencode用于文本域显示带的html代码
- IOS学习之WebView加载本地HTML代码或网络资源
- html5 css3 背景视频循环播放代码
- HTML5 标签audio添加网页背景音乐代码
- 我无法理解为什么我的代码中的单击选择文本
- js字符串与html代码互相转换时怪想法:自己解析js字符串成普通字
- 解决FCKEditor编辑器在浏览器返回时显示html源代码的问题
- 高分求:如何解析IdHTTP获得的http代码?用mshttp的IHTMLDocument2可
- 韩顺平_轻松搞定网页设计(html+css+javascript)_第19讲_js运行原