简体   繁体   中英

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

I am very new to Javascript. I am having problems refreshing and updating my JQuery Listview after adding some objects to the Listview. I am getting an error saying the listview refresh method is "Uncaught TypeError: undefined is not a function". 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. The most likely cause is that you're loading the library responsible for listview() too late or not at all.

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. 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');
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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