Wolfzmus Wolfzmus - 7 months ago 46
jQuery Question

datatables click even on last column

I have datatables like this code

var table = $("#mas-vendor");
var filter = $('.form-filter');
var target = table.attr('data-table');
var oTable = table.on( 'processing.dt', function ( e, settings, processing ) {
if (processing) {
$(this).find('tbody').addClass('load1 csspinner');
} else{
$(this).find('tbody').removeClass('load1 csspinner');
} ).DataTable({
"ajax": host+'datatable/'+target,
"bServerSide": true,
"iDisplayLength" : 10,
"order": [[ 1, "desc" ]],
"columnDefs": [{
"targets": [ 0 ],
"className": "details-control",

and the html like this

<table id="mas-vendor" class="dataTable table table-bordered table-hover table-full-width" width="100%" data-table="masvendor">
<th>Cheque/Giro Name</th>

on json like this (just example)

$json['data'][] = [$val['vendor'], $val['country'], $val['terms'], $val['cgname'], $val['ppn'], $val['NPWP'], $val['status'],'<a href="javascript:;" id="delete">Delete</a> || <a href="javascript:;" id="edit">Edit</a>'];

And my problem is i need even click on last column (action) not all column, and how do i know if id is delete or edit. Can someone help me??

i wanna try use this code,

table.find('tbody').on('click', 'td a', function (){});

but i'm still dont know how to use it on last column


Try this

table.find('tbody').on('click', 'td:last-child a', function (){});

It will make all rows of last column clickable.