无法读取未定义的属性“ Api”来加载响应数据表.js

Deb*_*ish 0 javascript datatables ruby-on-rails-4

我正在尝试在datatable..as中实现子行,如 https://datatables.net/extensions/sensitive/examples/child-rows/whole-row-control.html, 但现在我遇到一个错误,无法读取属性“ Api”未定义的 输入图像描述在这里

custom.js

 $(document).ready(function() {
   $('#example').DataTable( {
    responsive: {
        details: {
            type: 'column',
            target: 'tr'
        }
    },
    columnDefs: [ {
        className: 'control',
        orderable: false,
        targets:   0
    } ],
    order: [ 1, 'asc' ]
   } );
    } );
Run Code Online (Sandbox Code Playgroud)

index.html.erb

<table id="example" class="display nowrap" cellspacing="0" width="100%">
    <thead>
        <tr>
            <th></th>
            <th>First name</th>
            <th>Last name</th>
            <th>Position</th>
            <th>Office</th>
            <th>Age</th>
            <th>Start date</th>
            <th>Salary</th>
            <th>Extn.</th>
        </tr>
    </thead>
    <tfoot>
        <tr>
            <th></th>
            <th>First name</th>
            <th>Last name</th>
            <th>Position</th>
            <th>Office</th>
            <th>Age</th>
            <th>Start date</th>
            <th>Salary</th>
            <th>Extn.</th>
        </tr>
    </tfoot>
    <tbody>
        <tr>
            <td></td>
            <td>Tiger</td>
            <td>Nixon</td>
            <td>System Architect</td>
            <td>Edinburgh</td>
            <td>61</td>
            <td>2011/04/25</td>
            <td>$320,800</td>
            <td>5421</td>
        </tr>
        <tr>
            <td></td>
            <td>Garrett</td>
            <td>Winters</td>
            <td>Accountant</td>
            <td>Tokyo</td>
            <td>63</td>
            <td>2011/07/25</td>
            <td>$170,750</td>
            <td>8422</td>
        </tr>

.....
Run Code Online (Sandbox Code Playgroud)

现在我该怎么办?

Sta*_*kin 5

I was struggling with the same issue, the fix I found was quite simple: You need to reorganize the scripts you applying to your code so fixedColumns.min.js always comes after jquery.dataTables.min.js and your own created JS file last. example:

#The script version or source(cdn or local) may vary, just pay attention for jquery.dataTables.min.js and dataTables.fixedColumns.min.js 
<script type="text/javascript" src="https://cdn.datatables.net/1.10.11/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="https://cdn.datatables.net/fixedcolumns/3.2.1/js/dataTables.fixedColumns.min.js"></script>
<script type="text/javascript" src="myJsFile.js"></script>
Run Code Online (Sandbox Code Playgroud)