我正试图将一个DataTables基于编辑器的表插入到WordPress页面中(见此处),但我遇到了以下错误:TypeError: f[("editor_" + c)] is undefined
令人困惑的是,我使用jQuery(function ($) {
退出了noConflict
模式,但这个问题仍然存在。
有什么想法吗?
这是我用来构建表的jQuery:
jQuery(function ($) {
$( document ).ready(function(e) {
var editor = new $.fn.dataTable.Editor( {
"ajaxUrl": "../wp-content/plugins/contacts/php/table.wp_contacts.php",
"domTable": "#wp_contacts",
"fields": [
{
"label": "Contact",
"name": "contact",
"type": "text"
},
{
"label": "Company",
"name": "company",
"type": "text"
},
{
"label": "Email",
"name": "email",
"type": "text"
},
{
"label": "Phone",
"name": "phone",
"type": "text"
},
{
"label": "Fax",
"name": "fax",
"type": "text"
},
{
"label": "Tax ID",
"name": "tax_id",
"type": "text"
},
{
"label": "Address",
"name": "address",
"type": "text"
}
]
} );
$('#wp_contacts').dataTable( {
"sDom": "Tfrtip",
"sAjaxSource": "../wp-content/plugins/contacts/php/table.wp_contacts.php",
"aoColumns": [
{
"mData": "contact"
},
{
"mData": "company"
},
{
"mData": "email"
},
{
"mData": "phone"
},
{
"mData": "fax"
},
{
"mData": "tax_id"
},
{
"mData": "address"
}
],
"oTableTools": {
"sRowSelect": "multi",
"aButtons": [
{ "sExtends": "editor_create", "editor": editor },
{ "sExtends": "editor_edit", "editor": editor },
{ "sExtends": "editor_remove", "editor": editor }
]
}
} );
});
});
发现TableTools需要在Editor之前加载。一旦在编辑器之前为TableTools调用了"wp_enque_script",一切都正常了。