Since: Buttons 3.0.0

Function that is called when the button is destroyed.
Please note - this property requires the Buttons extension for DataTables.


This function is provided to allow button authors to be able to assign custom events to the host DataTable or the button's DOM node, and then cleanly remove those events when a button is destroyed, ensuring that there are no memory leaks.

Of particular interest when using this method and the buttons.buttons.init option to attach events, will be the buttons.buttons.namespace option (accessible as the namespace parameter of the third parameter passed into this function). The namespace option is a unique namespacing string for every button, allowing events to be correctly removed without accidentally also removing other events.


function destroy( dt, node, config )


The function given here is called when the button is destroyed either by a call to buttons().remove(), when the Buttons instance is destroyed (buttons().destroy()) or when the host DataTable is destroyed (destroy()). It is provided to allow authors to removed events from the button preventing memory leaks.


No return value is required or expected. No action is taken upon any value that is returned.


  • Value:

Default function depends upon the button type. Please refer to the button type documentation


Button which has mouse enter / leave (hover) event listeners:

new DataTable('#myTable', {
	layout: {
		topEnd: {
			buttons: [
					text: '',
					init: function (e, dt, node, config) {
						node.on('mouseenter' + config.namespace, function () {
							console.log('Mouse enter');

						node.on('mouseleave' + config.namespace, function () {
							console.log('Mouse leave');
					destroy: function (dt, node, config) {
						node.off('mouseenter' + config.namespace);
						node.off('mouseleave' + config.namespace);