由于实际上没有人发布最终答案,因此我正在跟进此问题,因为我遇到了同样的问题。
COS.coupon.table_columns_titles = new Array();
COS.coupon.table_columns_titles.push({"sTitle": "Code"});
COS.coupon.table_columns_titles.push({"sTitle": "Status"});
COS.coupon.table_columns_titles.push({"sTitle": "Date"});
COS.coupon.table_columns_titles.push({"sTitle": "","sClass": "hide"});
$j('#listcoupons').dataTable({
"bProcessing":true,
'bJQueryUI': true,
'sPaginationType': 'full_numbers',
'oLanguage': {'sSearch': 'Filter:', 'sEmptyTable': 'Processing...'},
'aoColumns': COS.coupon.table_columns_titles,
"sScrollX": "100%",
"iDisplayLength": 10,
"bAutoWidth": false
});
...
// So this is the on click. I'm referencing the tbody because it's there
// throughout all the pagination.
$j("table#listcoupons tbody").on("click", function(event) {
...
// This is how I'm refering the specific item I wanted.
// Then I do get the id from the hidden column.
$j(event.target).closest('tr').children('td').eq(1).text()
整个点击事件看起来像这样。
$j("table#listcoupons tbody").on("click", function(event) {
if ($j(event.target).closest('tr').children('td').eq(1).text() == 'Used') {
// do some stuff/show a dialog
} else {
// do some other stuff/show a different dialog
}
});