Adding dynamic option to JQM listview was successful in page1. After adding it, listview was refresh:
$('#list').listview('refresh');
Options was linked to page2. In page2 I have pagebeforeshow event:
$('#page2').live('pagebeforeshow', function (e, data) {
alert(data.prevPage.attr('id'));
});
data.prevPage.attr('id') is undefined when the option selected was the one added dynamically. But for the other option, no problem at all.
Why can’t I get page1 id when selecting dynamically added option in listview?
Your code should work, take a look at this example: http://jsfiddle.net/Gajotres/c2dU4/. I have recreated your case and everything is working just fine.
Example:
Are you maybe trying to pass some additional data through a href? And can you show us more of your code?