{hero}

buttons.buttons.destroy

Since: Buttons 1.0.0

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

Description

This property is an alias of the feature property buttons.buttons.destroy and can be used to configure the feature from the top level DataTables configuration object, rather than in the layout option (see example below). This lets you use the feature as a string rather than an object, but it does restrict the configuration if you were using multiple instances of the feature. Please refer to the documentation for buttons.buttons.destroy for full details and options that apply to this option.

If you are using DataTables 1.x, which does not have the layout option, use this property name, but referring to the documentation for buttons.buttons.destroy for full details.

Example

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

new DataTable('#myTable', {
	layout: {
		topStart: 'buttons'
	},
	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);
			}
		}
	]
});