【问题标题】:Remove form-inline class删除表单内联类
【发布时间】:2018-01-12 09:28:22
【问题描述】:

我在我的应用程序中使用材料设计引导数据表。

https://datatables.net/examples/styling/material.html

Bootstrap 的 form-inline 类与 datables 样式冲突。

html

<table id="example" class="mdl-data-table" cellspacing="0" width="100%">
    <thead>
        <tr>
            <th>Name</th>
            <th>Position</th>
            <th>Office</th>
            <th>Age</th>
            <th>Start date</th>
            <th>Salary</th>
        </tr>
    </thead>
    <tfoot>
        <tr>
            <th>Name</th>
            <th>Position</th>
            <th>Office</th>
            <th>Age</th>
            <th>Start date</th>
            <th>Salary</th>
        </tr>
    </tfoot>
    <tbody>
        <tr>
            <td>Tiger Nixon</td>
            <td>System Architect</td>
            <td>Edinburgh</td>
            <td>61</td>
            <td>2011/04/25</td>
            <td>$320,800</td>
        </tr>
        <tr>
            <td>Garrett Winters</td>
            <td>Accountant</td>
            <td>Tokyo</td>
            <td>63</td>
            <td>2011/07/25</td>
            <td>$170,750</td>
        </tr>
    </tbody>
</table>

脚本

<script type="text/javascript">
    $(document).ready(function() {      
        $('#example').DataTable( {
            columnDefs: [
                {
                    targets: [ 0, 1, 2 ],
                    className: 'mdl-data-table__cell--non-numeric'
                }
            ]
        } );

    } );

</script>

我已经看到了这个解决方案

https://datatables.net/forums/discussion/40105/prevent-form-inline-class.

但我收到此错误。

jquery-3.1.1.min.js:2 Uncaught ReferenceError: table is not defined

下面的代码究竟应该放在哪里?

$( table.table().container() ).removeClass( 'form-inline' );

【问题讨论】:

  • 为什么需要 .table()?删除课程?
  • 你不能只使用 $("table").removeClass( 'form-inline' ); ?
  • $("table").removeClass('form-inline');不工作
  • 如果可能,创建工作 sn-p。

标签: jquery html css twitter-bootstrap datatables


【解决方案1】:

试试这个代码

       <script type="text/javascript">
            $(document).ready(function() {      
               var table =  $('#example').DataTable( {
                    columnDefs: [
                        {
                            targets: [ 0, 1, 2 ],
                            className: 'mdl-data-table__cell--non-numeric'
                        }
                    ]
                } );

                $( table.table().container() ).removeClass( 'form-inline' );

            } );
        </script>

【讨论】:

    猜你喜欢
    • 2013-08-19
    • 1970-01-01
    • 2011-05-17
    • 2011-01-22
    • 2018-03-08
    • 1970-01-01
    • 1970-01-01
    • 2018-08-31
    • 1970-01-01
    相关资源
    最近更新 更多