简体   繁体   English

Javascript JQuery Listview刷新错误消息-未捕获的TypeError:undefined不是函数

[英]Javascript JQuery Listview Refresh Error Msg - Uncaught TypeError: undefined is not a function

I am very new to Javascript. 我对Java非常陌生。 I am having problems refreshing and updating my JQuery Listview after adding some objects to the Listview. 将一些对象添加到Listview后,我在刷新和更新JQuery Listview时遇到问题。 I am getting an error saying the listview refresh method is "Uncaught TypeError: undefined is not a function". 我收到一条错误消息,说listview刷新方法是“ Uncaught TypeError:未定义不是函数”。 Does anyone know what's going on? 有人知道发生了什么吗?

$('#FavouriteStockList').listview('refresh');

<ul id="FavouriteStockList" data-role="listview" data-filter="true" data-theme="c">

                                                                </ul>   

It means that you are calling listview() before jQuery knows what it is. 这意味着在jQuery知道它是什么之前,您正在调用listview() The most likely cause is that you're loading the library responsible for listview() too late or not at all. 最可能的原因是您加载负责listview()的库太晚或根本没有加载。

You can check whether it's being loaded at all by pressing F12 and pasting your snippet of JavaScript above into the console and pressing enter. 您可以通过按F12并将上面的JavaScript片段粘贴到控制台中并按Enter来检查它是否已全部加载。 If it works, you know it's being loaded properly and that the issue is that you're calling it before it's ready. 如果它可以正常工作,则表明它已正确加载,并且问题在于您在准备就绪之前就在调用它。

One possible solution is to make your script wait until the document is ready before running it, like so: 一种可能的解决方案是让脚本等到文档准备好后再运行它,如下所示:

$(document).ready(function(){
  $('#FavouriteStockList').listview('refresh');
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM