1
Hi I am facing some issue with KTDatatable dropdown edit for each row, datatable.on(‘click’, is not picking my click event, please help.
The click event is from bootstrap dropdown, 

我的代码如下 //Datatable code var KTDatatableRecordSelectionDemo = function() { //..... //..... columns: [{ }, //..... { field: 'Actions', title: 'Actions', template: function(row) { return '\\\\\\ Organization Details\class="dropdown-item" href="#"> Location and contact detials\ Tax settings and bank details\ Access rights \class="dropdown-item" href="#" id="one_another">个人资料图片和打印徽标\\\';},}]

        and here below the init datatable function



        var localSelectorDemo = function() {
        var datatable = $('#organizations').KTDatatable(options);
        //....
        //....
        datatable.on('click', '#form_organisation_details', function() {
            var dataId = $(this).attr("data-id");
            console.log(dataId);
        }

            }
        }
4

2 回答 2

2

您不能直接使用 onClick ,因为表未初始化,而是在加载表后使用类似这样的方法添加点击事件。

$(table_id).on('click', '.btn-edit', function(e){
        e.preventDefault();
            $.ajax({
                type: 'get',
                url: 'some link here',
                success: function (data) {
                    $("#response").html(data);
                },
            });
    });

并在表格本身中使用类似这样的东西在表格行中添加按钮

return Datatables::of($data)->addColumn('actions',function($row){
                return '<a title="Edit" class="btn-edit"><i class="la la-edit"></i></a>';
            })->rawColumns(['actions'])->make(true);
于 2019-08-08T14:19:58.507 回答
2

尝试从 build.json 配置资产中删除 dompurify。此插件清理数据表自定义 HTML 模板选项。

于 2019-12-03T11:01:49.100 回答