【发布时间】:2015-01-08 10:06:16
【问题描述】:
我必须将点击事件添加到动态列表视图中。当我单击此列表时,它会重定向到更多详细信息页面。我正在获取特定区域的可用酒店列表并插入到列表视图中。现在,当我单击任何特定列表时,酒店将重定向到更多详细信息页面。 检查以下可用酒店列表的图像列表视图。每家酒店都有唯一的 ID 因此,当我单击任何列表时,它将使用该唯一的酒店 ID 并从服务器获取该酒店的更多详细信息,并显示在该特定酒店的专用页面上。我的问题是我如何在动态列表视图中添加点击并传递唯一的酒店 ID,以便稍后我能够使用该酒店 ID 从服务器获取更多信息。
我的脚本代码,如何在动态列表中添加点击
<script>
$(document).ready(function(){
$("#btnReg").click(function(){
$("#listHotelsOptions").empty();
var distance = document.getElementById('distance_id').value;
var output="";
var hiddenId="";
$.ajax({
url:"http://192.168.1.4/Experiements/webservices/getHotels.php",
type:"GET",
dataType:"json",
data:{type:"login", Distance:distance},
ContentType:"application/json",
success: function(response){
console.log(response)
$.each(response, function(index,value){
output+='<li class="hotelDetails"><a href="#hotelPage" style="text-decoration:none;">
<img alt="chef" src="./images/chef.min.png" width="20px" height="20px" >'+value.Hotel.Name+'
has'+value.Hotel.Rooms+'</a></li>';
});
$(".hotelDetails").live('click',function(){
});
$("#listHotelsOption").append(output).listview().listview('refresh');
},
error: function(err){
alert(JSON.stringify(err));
}
}) //ajax
}); //click
}); //ready
</script>
【问题讨论】:
-
停止一次又一次地打开具有相同问题的新线程
标签: javascript jquery list cordova