Mantain data attributes or classes on added rows
Mantain data attributes or classes on added rows
vismark
Posts: 79Questions: 5Answers: 0
I'm adding rows to a table dynamically like this:
dt.row.add('<tr class="testClass" data-test="just testing"><td>test</td></tr>').draw();
Problem is that both class and data- attribute are stripped away in the redrown table. Is there a way I can easily and automatically preserve them?
This discussion has been closed.
Answers
I built an example similar to this for someone else.
Take a look at the btnGo2 event handler where I am adding a new row, then adding the class to the new row.
http://jsbin.com/yifofu/29/edit?html,css,js,output
In this particular case, they wanted the class removed after a few seconds so that is what the setTimeout does
Thanks Bindrid, i know i can add them manually. The question in fact was how to leave them already in, as per the html passed to build the row.