新的Bie:我有一個列表數據,使用json format
從數據庫中獲取並顯示到列表視圖中。但我仍然混淆瞭如何獲得列表視圖的選定索引,這是我的代碼:如何獲得選定的索引JQuery Mobile Listview
<script>
function loadListTips(){
$('#message').html('Loading...');
$.ajax({
type: 'get',
url: "http://10.0.2.2/compfest/ajax/belajar/list_tips.php",
success: function(response){
var html = '';
$.each(response, function(index,item){
html += '<li>';
html += '<a>';
html += '<span class="judul">' + item.judul + '</span>';
html += '</a>';
html += '</li>';
});
$('#penyakit_list').html(html);
$('#penyakit_list').listview('refresh');
$('#message').html('');
},
error: function(e){
alert('Error: ' + e);
}
});
}
</script>
希望有人幫助我。
「listview的選定索引」 - 你是什麼意思?你試圖在列表視圖中爲'a'標籤寫一個'click'事件嗎? – krishgopinath
是的,我想嘗試如何編寫基於索引的列表視圖的點擊事件.. –
任何需要使用索引?其實它有點不需要..爲什麼你需要索引? – krishgopinath