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,
我的代码如下
//数据表代码
var KTDatatableRecordSelectionDemo = function(){
// .....
// .....
列: [{
},
// .....
{
字段:“操作”,
标题:“操作”,
模板:功能(行){
返回'\\\\\\ Organization Details \ class =“ dropdown-item” href =“#”>位置和联系方式\税收设置和银行详细信息\访问权限\ 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);
}
}
}
最佳答案
您不能直接使用onClick,因为该表尚未初始化,而是在加载表后使用类似这样的方法来添加click事件。
$(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);
关于javascript - jQuery .on('click')不适用于KTDatatable每行编辑下拉菜单,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/57237993/