我正在使用数据表编辑器。当我尝试编辑并将其发布到服务器时,该行不断消失。刷新页面后,可以看到实际更新的数据。
这是我的代码片段。
var editor = new $.fn.dataTable.Editor({
ajax: "/ajax/clips/edit",
table: "#clips_table",
idSrc: "id",
fields: [
{
label: "Id",
name: "id",
type: "hidden"
},
{
label: "Player",
name: "player",
type: "select",
options: [
{ label: "Rooney", value: "Rooney" },
{ label: "Bale", value: "Bale" }
]
}
]
},
editorOpenValues;
editor.on('open', function() {
editorOpenValues = JSON.stringify(editor.get());
})
.on('preBlur', function () {
if (editorOpenValues !== JSON.stringify(editor.get())) {
this.submit();
}
});
$('#clips_table').DataTable({
dom: "lfrtip",
order: [[2, "asc"]],
columns: [
{data: "id"},
{data: "name"},
{data: "start"},
{data: "stop"},
{data: "player"}
]
});
$('#clips_table').on('click', 'tbody td.player', function () {
editor.inline(this);
});
这是服务器端脚本返回的 JSON 数据:
{
"data": {
"0": {
"id": "322",
"name": "Scoren 001",
"start": "00:11",
"stop": "00:31",
"player": "Rooney"
}
}
}
这个错误的可能原因是什么?