I have these three li's, which shows perfectly on screen using this addToListview-method. When I click one of these, it runs the "test()"-method, which is also good. But I need the "tempobj.name" (or the shown on-screen name) of the clicked field as a parameter, as in test(TextOnTheChosenLi);, since I need it to get the right "obj.page". How do I do that?
function addToListview(){
var listofitems = [];
var item1 = new Object;
var item2 = new Object;
var item3 = new Object;
item1.name = "item1"
item1.page = "info1"
item2.name = "item2"
item2.page = "info2"
item3.name = "item3"
item3.page = "info3"
listofitems.push(item1);
listofitems.push(item2);
listofitems.push(item3);
for (var i=0; i<listofitems.length; i++)
{
tempobj = listofitems[i];
$('ul').append($('<li/>', {
'data-role': "list-divider"
}).append($('<a/>', {
'href': 'somepage.html',
'onclick': 'test()',
'data-transition': 'slide',
'text': tempobj.name
})));
}
$('ul').listview('refresh');
}