Jeff Davidson
Jeff Davidson

Reputation: 1929

Using dataTables with another plugin for ajax

Okay I have a few things to ask about. I've included the jsfiddle version of my working page. I have implemented dataTables as well as a jconfirmaction plugin that was written. Say for example a user clicks on the delete icon for one of the contentpages which would bring up the confirm question and when the user clicks Yes what I would like it to do is go ahead and do an ajax somehow WITH dataTables so that it deletes it out of the database but also when it comes back then it removes it from the dataTable and refilters so that it'll update the table so that instead it'd be one less row which could mean restructuring the pagination.

http://jsfiddle.net/xtremer360/9hreh/

Upvotes: 1

Views: 421

Answers (2)

Keith.Abramo
Keith.Abramo

Reputation: 6955

Try calling

$("#my-table").fnDraw()

This tells datatables to hit the database again and redraw the data it gets back. Since your ajax call is going to delete that row, it will not return that data to datatables and thus datatables will not draw it.

fnDraw() is used a lot in the background of many of datatables action, like fnSort for example.

Upvotes: 1

Brian
Brian

Reputation: 8616

Once you've done your ajax call you need to call this function:

http://datatables.net/plug-ins/api#fnReloadAjax

Upvotes: 1

Related Questions