Wait for fnDraw to complete

Wait for fnDraw to complete

matbeardmatbeard Posts: 22Questions: 0Answers: 0
edited March 2012 in General
I have a dataTable setup to use server-side data. I also have an Ajax function that inserts a new row into the data using $.post and then calls fnDraw() in the success callback.

This is all working as expected -- click a button and a new row is inserted into the table.

I now want to manipulate the newly inserted row, but I need to wait until fnDraw() has completed before the new row exists in the DOM. I'm thinking maybe fnDrawCallback is what I'm looking for, but I can't figure out how to integrate it.

Here's what I have so far, so you can see what I'm getting at:
[code]
$.post("insert.php", rowData, function() {
oTable.fnDraw();
iRowIndex = $('#table tbody tr').length; //get the row index of the new row
editRow(iRowIndex); // call editRow function on the newly inserted row
});
[/code]

The editRow function converts the data in the specified row into edit boxes, so the entire row can be edited and saved. This function works, but when used as per the above, the fnDraw() completes after the edit boxes are created, thus replacing them.

Is there a way to wait until fnDraw() is complete?

Thanks

Replies

  • matbeardmatbeard Posts: 22Questions: 0Answers: 0
    Just realised I can do it with a setTimeout() function, but I was hoping for something a little more elegant.
This discussion has been closed.