DataTables nesting over and over on button click
DataTables nesting over and over on button click
I'm loading table data on button click. Each time I click the button to load the table data it keeps nesting another table inside each other. This is my button event.
[code]
$('#recent-data-table').dataTable( {
"bProcessing": true,
"sAjaxSource": 'ajax/mypage.php?search_class=cSearch&cust_id=' + $('#cust_id').html(),
"sPaginationType": "full_numbers",
"bJQueryUI": true,
"aaSorting": [[ 4, "desc" ]]
});
[/code]
[code]
$('#recent-data-table').dataTable( {
"bProcessing": true,
"sAjaxSource": 'ajax/mypage.php?search_class=cSearch&cust_id=' + $('#cust_id').html(),
"sPaginationType": "full_numbers",
"bJQueryUI": true,
"aaSorting": [[ 4, "desc" ]]
});
[/code]
This discussion has been closed.
Replies
It sounds like you are re-initialising your table on each event. You only need to initialise the table once, and can then reload the data using the fnReloadAjax plug-in: http://datatables.net/plug-ins/api#fnReloadAjax
Regards,
Allan
It looks like you are sending your parameters via GET, so you can do exactly that with fnReloadAjax:
[code]
oTable.fnReloadAjax( 'ajax/mypage.php?search_class=cSearch&cust_id=' + $('#cust_id').html() );
[/code]
And that should do it for you.
Regards,
Allan