admin管理员组

文章数量:1431770

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, 

My code is as follows //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"> Profile image and print logo\\\';},}]

        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);
        }

            }
        }
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, 

My code is as follows //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"> Profile image and print logo\\\';},}]

        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);
        }

            }
        }
Share Improve this question edited Jul 29, 2019 at 8:57 user3387166 asked Jul 28, 2019 at 4:39 user3387166user3387166 311 silver badge4 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 3

you can't use onClick directly because the table was not initialized instead use something like this to add the click event after the table is loaded.

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

and in the table itself use something like this to add the button in the table row

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);

Try to remove dompurify from the build.json config assets. This plugin sanitizes the datatable custom HTML template option.

本文标签: javascriptJQuery on(39click39) is not working with KTDatatable each row edit dropdown menuStack Overflow