我使用的是Avant的PHP模板(http://avant.redteamux.com/tables-editable.php)要创建一个可编辑表,您可以在其中选择表中的一行,当您单击"编辑"按钮时,会出现一个弹出窗口,其中包含此行中的字段。我正在尝试为此添加后端代码,该代码调用web服务来更新数据库。我所处的阶段是,单击"编辑"按钮,弹出窗口将按预期显示,我可以编辑字段,对web服务的调用成功。我的主要问题是如何在那之后关闭弹出窗口,并将更新反映在表中。我的代码是:
// editor is successfully initialized with jsondata
var table = $('#editable').dataTable({
"sDom":"<'row'<'col-sm-6'T><'col-sm-6'f>r>t<'row'<'col-sm-6'i><'col-sm-6'p>>",
"aaData":jsondata,
"bServerSide": false,
"bAutoWidth": false,
"bDestroy": true,
"aoColumns":columnsjson,
"oTableTools":{
"sRowSelect":"multi",
"aButtons":[
{ sExtends:"editor_create", editor:editor },
{ sExtends:"editor_edit", editor:editor,
"formButtons": [
{
label: "Update",
className: "btn-primary btn",
fn: function (e) {
// Code to call the service: this is successfull
// This is what I need to figure out, I've tried: editor.submit(); | $(this).close();
// (I tried several alternates for "this")
}
}
]
},
{ sExtends: "editor_remove", editor: editor }
});
谢谢。
所以它实际上很简单。这是对它的陈述:editor.close();