Create events dynamically for listview
Hi All,
Dynamically created the listview elements. I have to create event for those list items.
I tried like this :
- $.each(singles, function (key, value) {
- $("#Div1").append('<h4></h4><ul data-role="listview"><li><a href="#ShipsRef" onclick="fnTest(' + value.SHIP_CODE + ');">' + value.SHIP_CODE + '</a></li></ul>');
- $("#Div1").trigger("create");
- });
- function fnTest(obj) {
- alert(obj);
- }
- If i select the first list item, am able to get the value of the list item. If i click second item its throwing error as Undefined.
- Can you please advice/suggest how to avoid it?
Thanks
Divakar