There is a list view and this is loaded dynamically upon loading the page. This adds elements inside list view. The problem is i have placed backbutton.After going to previous screen and returning back to current screen it is loading the data and appending to the List View.
I need to remove the <li> elements from the list view.
The HTML code snippet.
<ul id="mymenu" data-role="listview" >
</ul>
Jquery Code Snippet.
$("#mypmenu").append('<li><a href='+ "#" + ' id="a" "> <img src="letterheader.png" >'+ this.textContent + ' </a> </li>');
Now i need to remove the elements from the list view (mymenu)which are loaded already.
Try emptying your list before appending list items first. Afterwards, make sure to call the refresh function of the listview widget, so jQuery Mobile will be rendering your list correctly.
$("#mypmenu").empty().append('<li><a href='+ "#" + ' id="a" "> <img src="letterheader.png" >'+ this.textContent + ' </a> </li>').listview("refresh");
See also http://forum.jquery.com/topic/dynamically-generated-listview
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With