我正在使用jQuery ajax動態地加載表格,表格的行有「contenteditable = true」,我正在嘗試爲每個單元格模糊事件進行偵聽,以便它觸發一個函數動態更新該單元格。 問題是,事件模糊並沒有被解僱,我嘗試了不同的選擇器(表,tbody,最後是整個文檔),但都是徒勞的。jQuery模糊事件沒有解僱表格單元格
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script type="text/javascript" src='jquery-1.8.3.js'></script>
<link rel="stylesheet" href='jquery-ui-1.8.7.custom.css' type="text/css">
<?php
include './datatable_include.php';
?>
<script type="text/javascript">
$(function() {
$.ajax({//create an ajax request to load_page.php
type: "GET",
url: "load_table.php",
dataType: "html", //expect html to be returned
success: function (response) {
$('#dataTable').find('tbody').html(response);
initDataTable('#dataTable', null);
}
});
});
$(document).bind("blur", "td", (function() {
// this code isn't reached
alert("ahoo");
var id = $(this).attr("id");
var name = $(this).attr("name");
var message_status = $("#status");
var value = $(this).text();
$.post('update_table.php', "id=" + id + "&" + name + "=" + value, function (data) {
if (data != '')
{
message_status.show();
message_status.text(data);
//hide the message
setTimeout(function() {
message_status.hide()
}, 3000);
}
});
}));
</script>
</head>
<body>
<table id="dataTable" width="700px" >
<thead>
<tr>
<th>Name</th>
<th>ID</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</body>
</html>
你嘗試'$(文件)。在(「模糊」 ...' – caramba
不幸的是,我必須使用「綁定」,而不是「上」,因爲的頁面使用過時的jQuery版本 – AbdulRahman
ooh我甚至沒有看過那個,你多次包括jQuery。那就不好了!爲了你的不幸,我沒有辦法解決那麼 – caramba