I’m having trouble phrasing my question. So I have a listview in jQuery mobile and it was created dynamically. Rather than link to an outside page when a list item is clicked, I just want to be able to grab the text of the item they clicked.
In my case its a list of names, and I want to know which one they clicked. I’ve created the list in HTML with:
<div data-role="content" data-theme="b">
<div id="friends_list_view" class="content-primary" data-theme="c">
<ul data-role="listview" data-filter="true" data-theme="c">
</ul>
</div>
</div>
When an item is clicked, I want to run some function using the name they have selected. How can I do that?
and then dynamically updated it later with:
var listString = null;
for(i in session_library){
listString = '<li><a href="#">'+session_library[i]['name']+'</a></li>';
$("#friends_list_view ul").append(listString);
}
$("#friends_list_view ul").listview('refresh');
Assuming that your listview will look like this:
you can register a click event handler which will give you the
<li>text back, e.g.Edit: Changed
vclicktoclick. See the documentation.