fnDestroy destroys too much

fnDestroy destroys too much

sronsieksronsiek Posts: 52Questions: 11Answers: 0
edited May 2013 in General
Some HTML:

[code]





<!-- div for splitter is inserted here -->



[/code]

The table tags are actually inserted dynamically using jquery and a data table attached
[code]
var oTable = j('#data_table').dataTable({ ... })
[/code]

Before the table is inserted, I use jquery.splitter to create a movable splitter bar between
upper & lower panes. This creates a div between the upper & lower pane divs which
is host to the splitter bar.

Now the upper-pane content may be replaced when the user clicks on something, for which
it is first cleared with:

[code]
clear_upper : function( id='#data_table' ) {
if ( j(id).length ) {
if ( j.fn.dataTable.fnIsDataTable( j(id).get(0) ) )
j(id).dataTable().fnDestroy( true )
}
j('#upper-pane').children().remove()
},
[/code]

The problem I'm observing is that the fnDestroy call also destroys the splitter div.
If I replace the splitter div with a static div tag (that does nothing), fnDestroy leaves
this in tact.

So, fnDestroy is breaking the splitter (regardless of true / false )

I've found a workaround, ok - more of a hack-around:

Instead of calling fnDestroy, I unbind all DT events (from DT code) and
'manually' remove everything within the upper-pane div:

[code]
$(oSettings.nTableWrapper).find('*').andSelf().unbind('.DT');
$('#upper-panel').children().remove()
[/code]

So, I have 2 questions:

1. Any idea why fnDestroy is breaking the splitter? This could lead to a clean fix.
2. Is the given hack-around considered safe?

Replies

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    It shouldn't be destroying any HTML other than that controlled by DataTables. Can you link to a test case showing the problem please: http://datatables.net/forums/discussion/12899/post-test-cases-when-asking-for-help-please-read

    Allan
This discussion has been closed.