Datatables 服务器端信息 + 带有 2 个按钮的静态列

Datatables serverside info + static colum with 2 buttons

我正在努力制作一个带有 2 个按钮的静态列,这些按钮触发 2 个带有动态数据的链接。我设法使 1 个按钮工作,但我无法使另一个按钮工作。我尝试为每个人添加一个 id 并为每个人调用不同的函数,但它似乎只适用于 $(\'#example tbody \') 而不是 ($(\'#customID \').

这是我的 js:

<script type="text/javascript">
           $(document).ready(function() {
    var table = $(\'#example\').DataTable( {
        "processing": true,
        "serverSide": true,
        "ajax": "app/server_processing.php",
        "columnDefs": [ {
            "targets": -1,
            "data": null,
            "defaultContent": "<button>Edit</button> <button>Delete</button>"
        } ]
    } );
     $(\'#example tbody \').on( \'click\', \'button\', function () {
        var data = table.row( $(this).parents(\'tr\') ).data();
        window.location.href = "index.php?categ=edit&id="+ data[0];
    } );
} );
        </script>

我修好了

<script type="text/javascript">
           $(document).ready(function() {
    var table = $(\'#example\').DataTable( {
        "processing": true,
        "serverSide": true,
        "ajax": "app/server_processing.php",
        "columnDefs": [ {
            "targets": -1,
            "data": null,
            "defaultContent": "<button id="edit">Edit</button> <button id="delete">Delete</button>"
        } ]
    } );
     $(\'#example tbody \').on( \'click\', \'#edit\', function () {
        var data = table.row( $(this).parents(\'tr\') ).data();
        window.location.href = "index.php?categ=edit&id="+ data[0];
    } );
 $(\'#example tbody \').on( \'click\', \'#delete\', function () {
        var data = table.row( $(this).parents(\'tr\') ).data();
        window.location.href = "index.php?categ=delete&id="+ data[0];
    } );
} );
        </script>