Hello guys! Hope someone here can help me with this. I'm just a newbie here regarding jQuery specially in mobile. I'm wondering if it is possible for me to add a dynamic list to my list? Search type, searchable if possible. I've been dealing with this for days already still wondering if it is possible.
Thanks!
- Login or Signup Now to post comments
#
Submitted by JOY Schilling on Tue, 2012-10-30 14:33.
Comment Id: 99362
Hi
Essentially I am trying to have a web page that is pretty basic to begin using jQuery. Once the page is loaded i want to populate a list (Dynamic List) with items. Here is what i have so far.
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a1/jquery.mobile-1.0a1.min.css" />
<script src="http://code.jquery.com/jquery-1.4.3.min.js"></script>
<script src="http://code.jquery.com/mobile/1.0a1/jquery.mobile-1.0a1.min.js"></script>
<script type="text/javascript">
$(document).ready(function()
{
var parent = document.getElementById('content');
var listview = document.createElement('ul');
listview.setAttribute('id','listview');
listview.setAttribute('data-role','listview');
listview.setAttribute('data-inset','true');
listview.setAttribute('data-theme','c');
listview.setAttribute('data-dividertheme','b');
var listdiv = document.createElement('li');
listdiv.setAttribute('id','listdiv');
listdiv.setAttribute('data-role','list-divider');
listdiv.innerHTML = "List of Items";
var listItem = document.createElement('li');
listItem.setAttribute('id','listitem');
listItem.innerHTML = "FIRST ITEM";
parent.appendChild(listview);
listview.appendChild(listdiv);
listview.appendChild(listItem);
});
$(listview).listview('refresh');
</script>
</head>
<body>
<div data-role="page">
<div data-role="header" id="header">
<h1>Items</h1>
</div><!-- /header -->
<div data-role="content" id="content">
<button type="button" onclick=addItem();>Click Me!</button>
</div><!-- /content -->
</div><!-- /page -->
</body>
</html>
So in the ready function, i want a list to be created and made with some elements. This works.
- Login or Signup Now to post comments

