Highlight logged in user in table
Highlight logged in user in table
Is there a way to fire off a vanilla javascript functon when the pagination buttons are clicked, or the search is activated.
I have a JavaScript function (“DomContentLoaded”) that highlights a logged in user in my DataTables table, but it only works if the user is on the first page. If the user is on any other page, they are not highlighted.
I can get it to work by running the same function with, click or key down events but even to a beginner it looks like a lot of redundant code.
I would greatly appreciate a nudge in the right direction
This question has an accepted answers - jump to answer
Answers
I would look at using
createdRow
, like this example. Move your DomContentLoaded functionality into this callbackTo answer your question you can use
draw
to run your function every time the table is drawn, ie, search, sort or page. It would be more efficient to usecreatedRow
but might require refactoring your DomContentLoaded code.Kevin
Thanks Kevin, I will work on both those options.