{hero}

buttons().action()

Since: Buttons 1.0.0

Get / set the action functions for the selected buttons.
Please note - this property requires the Buttons extension for DataTables.

Description

This method provides the ability to get or set the action function of the selected buttons. The action function (which can be set on initialisation by buttons.buttons.action) defines what the button will do when activated.

Please note that when setting an action, the new function will replace any action that the button already has assigned to it. This is an important consideration as many button types define their own action that would no longer be executed if replaced.

Types

function buttons().action()

Description:

Get the action functions for the selected buttons.

Returns:

DataTables API instance which contains the action functions for the selected buttons

function buttons().action( set )

Description:

Set the action functions for the selected buttons.

Parameters:
Returns:

DataTables API instance with the selected buttons in the result set, available for chaining further operations on the buttons.

Example

Set a simple action function for all buttons:

var table = new DataTable('#myTable');

table.buttons().action(function (e, dt, button, config) {
	console.log('Button ' + this.text() + ' activated');
	this.disable();
});