有没有办法,因为我迭代通过JSON文件关联某些数组元素与点击处理程序的列表?关联JSON数组元素与事件处理程序
什么我是这样的:
$.ajax(
{
url: 'json/data.json',
dataType : 'json',
type: 'get',
cache: false,
success: function(fullJSONData)
{
$(fullJSONData.events).each(function(index, oneJSONLine)
{
$('#eventList').append(newEvent(index, oneJSONLine))
$("#eventItem" + index).on("click", showEvent (fullJSONData.events[index]));
});
},
error: function (e)
{
console.log("error " + e.message);
}
});
这不是工作,因为所有的showEvent事件处理程序()指向的最后一个值,这是在指数。我能以某种方式解决这个问题吗?
谢谢
感谢那@charlietfl,很好的学习差异 – Scone