RemoveClass Row_Selected not working
RemoveClass Row_Selected not working
jlivingston
Posts: 13Questions: 0Answers: 0
http://debug.datatables.net/ebuxuw
I can select a row and it will highlight. If I select a second row it will also highlight but I want, also, for the first rows highlight to disappear but it is not working. Please advise.
I can select a row and it will highlight. If I select a second row it will also highlight but I want, also, for the first rows highlight to disappear but it is not working. Please advise.
This discussion has been closed.
Replies
Allan
$('#datalist tbody tr').live('click', function (event) {
$(oTable.fnSettings().aoData).each(function (){
$(this.nTr).find("td").removeClass('row_selected');
});
$(event.target).parent().find("td").addClass('row-modified');
} );
I would suggest never using the contents of fnSettings. You should be able to get the information you need via the API. In this case fnGetNodes or the `$` method.
Allan
$('#datalist tbody tr').live('click', function (event) {
$(oTable.fnGetNodes()).each(function (){
$(this.nTr).find("td").removeClass('row-modified');
});
$(event.target).parent().find("td").addClass('row-modified');
} );
The rows highlight OK but remain highlighted when selected in other rows. If I remove this completely then the selected row does not highlight. I added a debugger line in the EACH section and it is definitely going through that section (I have ten rows and it hit the debugger line 10 times.).
Can you not just do:
[code]
$('td.row-modified', oTable.fnGetNodes() ).removeClass( 'row-modified' );
[/code]
Allan
$('#datalist tbody tr').live('click', function (event) {
$(oTable.fnGetNodes()).each(function (){
$(this.nTr).find("td").removeClass('row-modified');
});
$(event.target).parent().find("td").addClass('row-modified');
} );
and added this to the style section:
.row_selected
{
background-color: #ccc !important;
}
Now it works.