Reputation: 139
I trying to select the value from a row using a button from same row. It is like each row the list have its own button. Currently my application can show all the items in the list but it select all the item in the listview. How can I do it?
Javascript of appending button with list. #listData is my listview id.
$('#listData').append('<li>'+resultset.rows.item(i).name+'<input type="image" value="view" src="img/view.png" alt="button" width="20" height="20"/></li>').listview('refresh');
$('#listData').on('click','input', function(e) {
e.stopImmediatePropagation();
var btn = $(this).val();
if (btn == "view"){
$('#listData').on('click', function() {
alert('Selected Name=' + $(this).text());
});
}
});
Upvotes: 0
Views: 104
Reputation: 218
Give separate id for each row like this.
$('#listData').append('< li >' + resultset.rows.item(i).name + '< input type="image" value="view" src="img/view.png" alt="button" width="20" height="20" id ="id'+i+'"/ >< /li >') .listview('refresh');
Upvotes: 1