DataTables nesting over and over on button click

DataTables nesting over and over on button click

djonesdjones Posts: 2Questions: 0Answers: 0
edited September 2009 in General
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]

Replies

  • allanallan Posts: 63,602Questions: 1Answers: 10,486 Site admin
    Hi djones,

    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
  • djonesdjones Posts: 2Questions: 0Answers: 0
    How do I send parameters with fnReloadAjax? The data is only loaded when a date range is chosen. When the user selects a date range they click the submit button. Then it loads the table data. The user will be changing the date range regularly. So, my problem is when the user chooses a date range and clicks the submit button, then chooses another date range and clicks the submit button again. The tables are nested inside each other.
  • allanallan Posts: 63,602Questions: 1Answers: 10,486 Site admin
    HI djones,

    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
This discussion has been closed.