工作我使用jQuery(1.6.2)的舊版本,似乎無法獲得委託的工作。我有一個列表,我試圖用一個單擊事件委託,但它重新加載列表後失敗。jQuery的委託不具有列表項
這裏是我當前的代碼:
$(".image_result").delegate("li", "click", function() {
//$('.image_result li').click(function() {
var imgInfo = $(this).attr('id').split(':');
if(confirm('Are you sure you want to delete this image?')) {
$.post('delete_image.php?image_id=' + imgInfo[0] + '&user_id=' + imgInfo[1], function(data) {
if (data.st) {
var resp = data.html.split("|");
$('#imageStats').html(resp[0]);
$('#imageTable').html(resp[1]);
}
else {
alert("Yikes, something went wrong");
}
}, "json");
}
});
的imageTable格設置現在擁有新的列表項(image_result)
我缺少什麼?
你可以張貼HTML結構以及 – frictionlesspulley 2011-12-31 02:59:47
當你重新加載列表,你清理掉,並重新建立LIS,或者是你破壞並重新創建.image_result元素? – 2011-12-31 03:01:57