dton37910 2015-12-22 15:14
浏览 145

Datatable-bootstrap仅适用于第一页。

I'm new to datatable-bootstrap. I have edit button and delete button, when i press edit button, it works fine on first page only.From 2nd page it doesn't work. How to refresh the datatable (only table) after deleting?

For refreshing table(after DELETING)

This code is working only one time, if i click again on another button, it doesn't work

$('table').load(location.href + " table");

php file for datatable

<script>
    $(document).ready(function() {
         $('#vehicle-list').dataTable();         
    } );   
</script>


<table class="table table-hover myTable" id="vehicle-list">
        <thead>
            <tr>
                <th>No</th>
                <th>No plate</th>
                <th>Type</th>
                <th>A/C</th>
                <th>Fuel</th>                    
                <th>Action</th>
            </tr>
        </thead>
        <tbody>
            <?php
                include 'inc/connection.php';

                $que="SELECT * FROM vehicle_register";
                $query_run=mysqli_query($con,$que);
                $no=1;

                while($row=mysqli_fetch_array($query_run))
                {              
            ?>
                <tr>
                    <td><?php echo $no++; ?></td>
                    <td><?php echo $row['no_plate']; ?></td>
                    <td><?php echo $row['vehicle_type']; ?></td>
                    <td><?php echo $row['ac_type']; ?></td>
                    <td><?php echo $row['fuel_type']; ?></td>

                    <td><div class="btn-group"><a class='Edit btn btn-primary' data-toggle="modal" href="#form_modal" data-target="#myModal" data-Id="<?php echo $row['no_plate'];?>">Edit</a><a class='Delete btn btn-danger' data-toggle="modal" href="#form_modal" data-target="#myModal" data-Id="<?php echo $row['no_plate'];?>">Delete</a></div>
    </td>                       

                </tr>
            <?php
                }
                mysqli_close($con);
            ?>
        </tbody>
    </table>
  • 写回答

1条回答 默认 最新

  • dongnei3634 2015-12-22 15:27
    关注

    You should call $('#vehicle-list').dataTable(); as a callback for your load function as $(document).ready() is only happening on page load.

    $('table').load(location.href + " table", function(){
         $('#vehicle-list').dataTable();
    });
    
    评论

报告相同问题?

悬赏问题

  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么