我有一个条件column == 1
,如果是这样的话,功能MakeCellsEditable
和功能myCallbackFunction
初始化:如何在执行后终止我的所有功能?
<script src="https://raw.githubusercontent.com/ejbeaty/CellEdit/master/js/dataTables.cellEdit.js"></script>
$(document).ready(function() {
var table = $('#myTable').DataTable();
$('#myTable tbody').on('mousedown', 'td', function() {
$('#myTable').data('column', table.cell(this).index().columnVisible);
});
if (column == 1) {
table.MakeCellsEditable({
"onUpdate": myCallbackFunction
});
}
});
function myCallbackFunction(updatedCell, updatedRow, oldValue) {
var array = updatedRow.data();
var id = array[0];
var column = $('#myTable').data('column');
console.log("The column is: " + column);
jQuery.ajax({
type: "POST",
url: "update.php",
data: {
updatedCell: updatedCell.data(),
id: id,
column: column,
},
cache: false
});
}
我想要做的是,该功能被执行后,我要杀死他们。因为否则,如果我一次点击第1列,那么我所有的表格都是可编辑的(不仅是第1列)。 我试过table.unbind();
或table.die()
,但这并没有奏效。
我在代码的最后测试:
function destroyTable() {
if ($.fn.DataTable.isDataTable('#myTable')) {
table.destroy();
table.MakeCellsEditable("destroy");
}
}
但它没有工作
你有没有读过https://github.com/ejbeaty/CellEdit? 'table.MakeCellsEditable(“摧毁”);' –
哦,还没有看到这个! – Jarla
但是我测试过'table.MakeCellsEditable(“destroy”);'不幸的是它没有工作 – Jarla