I have a Bootstrap Table. If the user clicks on a specific cell (Delete), I would like to highlight the row red. I am using the click-cell.bs.table
, but nothing happens when I click on a cell.
$table.on("click-cell.bs.table", function (field, value, row, $element) {
if (field == 'Delete') {
$element.parent().toggleClass('bg_delete');
}
});
The function needs events as its first parameter.
And two minor issues: 1) Correct $table
to $('#table')
and 2) Remove parent
function.
Here is the solution:
$('#table').on("click-cell.bs.table", function (e, field, value, row, $element) {
if (field === 'Delete') {
$element.toggleClass('bg_delete');
}
});