Is postRemove the right event to count rows in the table?
Is postRemove the right event to count rows in the table?
swrobel
Posts: 10Questions: 2Answers: 0
The removed row still seems to be present in the DOM on postRemove.
> $('#template tbody').find('tr').length
4
Code:
editor.on('postRemove', function(e, type) {
console.log($('#template tbody').find('tr').length);
});
Output (first line is from the event handler):
4
> $('#template tbody').find('tr').length
3
If this isn't the right event, what should I be using so I can properly count the rows left in the DOM?
Debug: http://debug.datatables.net/okatej
Also worth mentioning that we have an Editor license, just under a different account at my organization.
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Hi,
Yes, at the point of the
postRemove
event the table has not yet been redrawn, so the row is still present (although really in a "detached" state since the next draw will remove it.The draw is the next event that happens. The
submitComplete
event might be the best option here.Allan
edit I've added full forum access to your account now :-)
Allan, thanks for the reply! submitComplete works, but is there any way to listen for that event only when related to a 'remove' event? I noticed that event fires for any editor action that submits back to the server.
What you could do is:
I've used
off
and a namespace in case you are using multiple row deletion.postRemove
will execute once for each row that was removed.Allan