javascript - how to use jquery-mobile listview to link to inner pages with UrlVars? -


i have problem jquery-mobile listview.

i inner pages (#page1, #page2,..) same html file. e.g. in #page2, have jquery listview object:

<ul id="itemlist" data-role="listview"></ul>   

each item of listview has url inner page plus index generated in js file head of html file. of code js file:

$.each(data, function(index, record) { $('#itemlist').append('<li><a href="#page2?id=' +  record.id + '"></a></li>'); }); $('#itemlist').listview('refresh'); 

the mouse on items shows differents links each index "id". only first click works , goes correct page e.g. page2?id=id1 returning page listview , clicking on item e.g. /page2?id=id2, page displayed previous (the first link clicked) page id1

it problem of urlvars notation? when used href="page.html?id=.... or href="#page without additional indexes there no problem , listview works fine. href="#page?id=... dosen't work. sound refresh problem? maybe related dom?

any idea?

i'm sorry, not know if have explained problem correctly.

thank you! best regards.

try following:

$.each(data, function(index, record) {     $('#itemlist').append('<li><a href="#page2?id=' +  record.id + '">' + record.id + '</a></li>'); }); 

you don't have repeat code since looping on same piece inside each function.


Comments