destroy

Since: DataTables 1.10

Table destroy event - fired when a table is destroyed.

Description

The destroy event is fired when a DataTable is torn down, to be replaced with an enhanced HTML table (or simply removed from the DOM altogether). This can be used to remove bound events, added DOM nodes etc and can be particularly useful for plug-in authors.

This event is fired when the DataTable is destroyed by calling destroy API method or passing the destroy parameter in the initialisation object.

Please note that, as with all DataTables emitted events, this event is triggered with the dt namespace. As such, to listen for this event, you must also use the dt namespace by simply appending .dt to your event name, as shown in the example below.

Type

function function( e, settings )

Parameters:

Example

Remove bound events on table destroy:

$('#example')
	.dataTable()
	.on( 'click', 'td', function () {
		alert( this.innerHTML );
	} );

$('#example').on( 'destroy.dt', function ( e, settings ) {
	$(this).off( 'click', 'td' );
} );

Related

The following options are directly related and may also be useful in your application development.