Jquery Datatable Highlight Drops Off After Reload
I have a datatable which uses ajax to load the values. var table = $('#example').DataTable({ 'ajax': 'xxxxxx.aspx', stateSave: true, 'aLengthMenu': [ [10, 2
Solution 1:
You could do something like that :
function highlight() {
$('#example tbody').on('click', 'tr', function () {
if ($(this).hasClass('selected')) {
$(this).removeClass('selected');
} else {
table.$('tr.selected').removeClass('selected');
$(this).addClass('selected');
}
});
}
$(document).ready(function () {
// Call the function at document ready
highlight();
// Call the ajax and the function every 5 seconds
setInterval( function () {
table.ajax.reload(null, false);
highlight();
}, 5000 );
});
Post a Comment for "Jquery Datatable Highlight Drops Off After Reload"