无法读取空属性'nTable'

时间:2022-12-09 14:29:29

I recently set up my first try with datatables.

我最近首次尝试使用datatables。

When I test my Site I'll get a few errors in my console.... Anyone got an idea how to solve them?

当我测试我的网站我将得到一些错误在我的控制台....有人知道怎么解决吗?

Uncaught TypeError: Cannot read property 'nTable' of null
_fnCallbackFire @ jquery.dataTables.js:5242
_fnLog @ jquery.dataTables.js:5070
(anonymous function) @ jquery.dataTables.js:6111
m.extend.each @ jquery.js:2
m.fn.m.each @ jquery.js:2
DataTable @ jquery.dataTables.js:6092
$.fn.DataTable @ jquery.dataTables.js:14775
(anonymous function) @ datatable.php:134
m.Callbacks.j @ jquery.js:2
m.Callbacks.k.fireWith @ jquery.js:2
m.extend.ready @ jquery.js:2
J @ jquery.js:2

The Scripts are loaded in the header section. via including the header.php It doesn't change anything when i put the directly into the page.

脚本加载在header部分。通过包括标题。当我把它放到页面上时它不会改变任何东西。

The following scripts are loaded:

下载以下脚本:

<script type="text/javascript" charset="utf-8" src="/assets/js/jquery.js"></script>
<script type="text/javascript" charset="utf-8" src="/assets/js/jquery.dataTables.js"></script>
<script type="text/javascript" charset="utf-8" src="/assets/js/dataTables.tableTools.js"></script>
<script type="text/javascript" charset="utf-8" src="/assets/js/dataTables.editor.js"></script>

Versions:

版本:

  • jQuery v1.11.3
  • jQuery v1.11.3
  • DataTables 1.10.7
  • datatable 1.10.7
  • TableTools 2.2.4
  • TableTools 2.2.4
  • dataTables.editor 1.4.2
  • datatable中。1.4.2编辑

You can find my Code right here: https://ghostbin.com/paste/46x7v

您可以在这里找到我的代码:https://ghostbin.com/paste/46x7v

1 个解决方案

#1


0  

You have a typo in DataTables initialization code where colums should be columns instead.

您在DataTables初始化代码中有一个typo,其中列应该是列。

$('#adminlist').DataTable( {
    dom: "Tfrtip",
    ajax: "assets/php/table.admins.php",
    columns: [
        {data: "id" },
        {data: "name" },
        {data: "joindate" },
        {data: "section" },
        {data: "tutor" },
        {data: "lesson1" },
        {data: "lesson2" },
        {data: "lesson3" },
        {data: "versus" },
        {data: "insults" }
    ],
    tableTools: {
        sRowSelected: "os",
        aButtons: [
            { sExtends: "editor_create", editor: editor },
            { sExtends: "editor_edit",   editor: editor },
            { sExtends: "editor_remove", editor: editor }
        ]
    }
});

Also your tag <section class="container" is not closed, should be <section class="container">.

您的标签

#1


0  

You have a typo in DataTables initialization code where colums should be columns instead.

您在DataTables初始化代码中有一个typo,其中列应该是列。

$('#adminlist').DataTable( {
    dom: "Tfrtip",
    ajax: "assets/php/table.admins.php",
    columns: [
        {data: "id" },
        {data: "name" },
        {data: "joindate" },
        {data: "section" },
        {data: "tutor" },
        {data: "lesson1" },
        {data: "lesson2" },
        {data: "lesson3" },
        {data: "versus" },
        {data: "insults" }
    ],
    tableTools: {
        sRowSelected: "os",
        aButtons: [
            { sExtends: "editor_create", editor: editor },
            { sExtends: "editor_edit",   editor: editor },
            { sExtends: "editor_remove", editor: editor }
        ]
    }
});

Also your tag <section class="container" is not closed, should be <section class="container">.

您的标签