Javascript JQuery Mobile没有方法“listview()”
下面的代码显示了一个函数cacheListPrint,它是使用Phonegap从JQuery移动框架“主页”上按钮的onclick元素调用的 下面的HTML显示了从“主页”的href元素加载的目标页面 cacheListPrint函数从SQLLite数据库检索数据,然后使用该数据库动态创建无序列表并将其填充为JQuery viewlistelement 加载页面时,viewlist不会格式化,只显示从数据库检索到的每个元素的文本标题和图像。数据正在显示,并且与从数据库请求的数据一致-因此我知道列表已成功创建,但无法正确呈现 我已尝试使用$'placeslist'.viewlist;&$'placeslist'.viewlist'refresh';在当前进行.trigger“create”引用的位置。他们两个都不工作。我还尝试将.trigger'create'语句上移到声明的下一行 此外,当调用任一viewlist时。。。函数时,在Eclipse调试终端中引发以下错误: 未捕获的TypeError:对象[Object Object]没有方法“listview”-显然表明viewlist是一个未知的方法调用Javascript JQuery Mobile没有方法“listview()”,javascript,cordova,jquery-mobile,Javascript,Cordova,Jquery Mobile,下面的代码显示了一个函数cacheListPrint,它是使用Phonegap从JQuery移动框架“主页”上按钮的onclick元素调用的 下面的HTML显示了从“主页”的href元素加载的目标页面 cacheListPrint函数从SQLLite数据库检索数据,然后使用该数据库动态创建无序列表并将其填充为JQuery viewlistelement 加载页面时,viewlist不会格式化,只显示从数据库检索到的每个元素的文本标题和图像。数据正在显示,并且与从数据库请求的数据一致-因此我知道列
function cacheListPrint() {
db.transaction(queryDBPrint, errorCB);
}
function queryDBPrint(tx) {
tx.executeSql('SELECT * FROM cache', [], querySuccessPrint, errorCB);
}
function querySuccessPrint(tx, results) {
$('#placeslistcontainer').empty();
$('#placeslistcontainer').html('<ul id="placeslist" data-filter="true"></ul>');
$.each(results.rows, function(index){
var row = results.rows.item(index);
$("#placeslist").append('<li><a href="#"><h1>'+row['name']+'</h1><img src="'+row['image']+'" /></a></li>');
});
$("#cachelist").trigger('create');
}
function errorCB(err) {
alert("Error processing SQL: "+err.code);
}
<div data-role="page" id="cachelist" data-transition="none"> <!-- Start of cache list screen -->
<header data-role="header">
<h1>Cache List</h1>
<a href="#home" data-icon="home" data-transition="none">Home</a>
</header>
<div data-role="content" id="placeslistcontainer">
</div>
<footer data-role="footer" data-position="fixed">
</footer>
</div> <!-- End of cache list screen -->
我已经广泛阅读了jquerymobileapi,并花了几个小时在谷歌上搜索这个问题——许多“存在”的建议在考虑它们时是有意义的,但在实现时却不起作用。我对实现建议很有信心,但JQuery和Javascript对我来说是相对较新的语言-因此,如果您能提供必要的基本分类,我们将不胜感激
$("#placeslistcontainer ul").listview();
listviewrefresh;更新现有listview时似乎有效。我收到了相同的错误消息。修正了我在deviceready事件中包装所有应用程序代码后的问题,Phonegap说这很重要: