Add item to listview
Description
The following code shows how to add item to listview.
Example
<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
src='http://code.jquery.com/jquery-1.8.3.js'></script>
<script type="text/javascript"
src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.js"></script>
<link rel="stylesheet" type="text/css"
href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.css">
<script type='text/javascript'>//<![CDATA[
$(window).load(function(){<!--from ww w . ja va 2 s .c o m-->
$(".mylist").on("vclick", function(e){
var item = $(e.target).closest("li");
var newItem = '<li><a href="#">New Item</a></li>';
item.hide(500);
setTimeout(function(e){
item.remove();
$(".mylist").append(newItem).listview("refresh");
}, 500);
});
});//]]>
</script>
</head>
<body>
<div data-role="content">
<ul data-role="listview" data-inset="true" data-filter="true"
class="mylist">
<li><a href="#">Test</a></li>
</ul>
</div>
</body>
</html>