庫版本:
的jQuery 2.1.1
數據表:1.10.1-dev的
dataTablesTableTools:2.2.1
dataTables.dataTables。 editor.min.js:1.2.3
我試圖使用datatableseditor使用骨幹,RequireJS實現CRUD操作和Datatables.But我收到錯誤消息:
$.fn.dataTable.Editor is not a constructor"
可能是什麼原因?
這裏是我的配置:
require.config({
baseUrl: 'js',
paths: {
jquery: 'vendor/jquery.min',
datatables: 'vendor/jquery.dataTables.min',
datatablesTableTools: 'vendor/dataTables.tableTools.min',
datatablesEditor: 'vendor/dataTables.editor.min'
},
shim: {
jquery : {
exports : '$'
},
datatables: {
deps: [
'jquery',
]
},
datatablesTableTools: { deps: ['datatables'] },
datatablesEditor: { deps: ['datatables'] }
}
});
使用它,如下所示:
require(["jquery", "datatables"], function() {
var editor = new $.fn.dataTable.Editor({
"ajax": "table.line.php"
});
$('#myGrid').dataTable({
"aaData": [
['Trident', 'Internet Explorer 4.0', 'Win 95+', 4, 'X'],
['Trident', 'Internet Explorer 5.0', 'Win 95+', 5, 'C']
],
"aoColumns": [
{ "sTitle": "Engine" },
{ "sTitle": "Browser" },
{ "sTitle": "Platform" },
{ "sTitle": "Version" },
{ "sTitle": "Grade" }
],
"tableTools": {
"sRowSelect": "os",
"aButtons": [
{ "sExtends": "editor_create", "editor": editor },
{ "sExtends": "editor_edit", "editor": editor },
{ "sExtends": "editor_remove", "editor": editor }
]
}
});
});