Highlight logged in user in table

Highlight logged in user in table

atatayloratataylor Posts: 35Questions: 7Answers: 0

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

  • kthorngrenkthorngren Posts: 20,309Questions: 26Answers: 4,769
    Answer ✓

    I would look at using createdRow, like this example. Move your DomContentLoaded functionality into this callback

    Is there a way to fire off a vanilla javascript functon when the pagination buttons are clicked, or the search is activated.

    To 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 use createdRow but might require refactoring your DomContentLoaded code.

    Kevin

  • atatayloratataylor Posts: 35Questions: 7Answers: 0

    Thanks Kevin, I will work on both those options.

Sign In or Register to comment.