0
我想在listview上使用data-filter =「true」功能。我發現它只適用於靜態列表(即所有li元素都列在html文件中)。動態生成列表不起作用。似乎需要以某種方式重新初始化。這裏是我的嘗試:如何使jQuery搜索與動態列表視圖一起工作?
<!DOCTYPE html>
<html>
<head>
<title>View Events</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="shortcut icon" href="favicon.ico" />
<link rel="stylesheet"
href="script/jquery.mobile-1.1.0/jquery.mobile-1.1.0.min.css" />
<script type="text/javascript" src="script/jquery-1.7.2.min.js"></script>
<script type="text/javascript"
src="script/jquery.mobile-1.1.0/jquery.mobile-1.1.0.min.js"></script>
<script type="text/javascript" src="script/pure_min.js"></script>
</head>
<body>
<div data-role="page" id="view-events">
<div data-role="header" data-id="header" data-position="fixed">
<h3>
View Events of <span id="events-for-pump-id" class="pump-id">...</span>
</h3>
</div>
<div data-role="content">
<ul id="events" data-role="listview" style="display: none;" data-filter="true">
<li class="events code"></li>
</ul>
</div>
<script type="text/javascript">
$(document).on('pageinit', '#view-events', function() {
$('#events-for-pump-id').autoRender({
'pump-id' : 123
});
$('#events').autoRender({
events : [ {
code : 1
}, {
code : 2
}, {
code : 3
} ]
});
$('#events').show();
});
</script>
</div>
</body>
</html>