{hero}

buttons.buttons.namespace

Since: Buttons 3.0.0

Unique namespace for every button.
Please note - this property requires the Buttons extension for DataTables.

Description

It can often be useful for authors to be able to add events to a button or DataTable when using the buttons.buttons.init option to take some action when a trigger is activated on the page. In order to be able to cleanly remove the attached events and prevent possible memory leaks form these event listeners, Buttons will automatically generate a namespace string for each button. The buttons.buttons.destroy option can be used to define a function that will remove the event listeners added.

It is possible to define your own namespace, however it is strongly recommended that you do not provide a custom value, instead allowing Buttons to assign its own value. There is no benefit in assigning your own namespace!

This parameter is documented primarily so you know that it exists and is automatically generated by Buttons.

Type

string

Description:

If given, this string should be unique for every button created on the page, with a leaving period (.). However, it is strongly recommended that you do not set this parameter - allow Buttons to assign a unique value.

Default

  • Value: null

Default value is automatically assigned by Buttons

Example

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);
					}
				}
			]
		}
	}
});