Reputation: 9243
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');
}
});
Upvotes: 0
Views: 958
Reputation: 1588
You need to change a little bit of CSS. Please have a look.
see sample code below http://jsfiddle.net/4ek2znw3/
#table .bg_delete td {
background-color: #ff0000 !important;
opacity: 0.5 !important;
}
Upvotes: 1
Reputation: 512
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');
}
});
Upvotes: 2