buttons-action
A button's action method has been triggered.
Please note - this property requires the Buttons extension for DataTables.
Description
This event is triggered whenever a button's action
method is triggered by the end user (via keyboard, mouse or touch) or by the API (button().trigger()
). It provides information about the button that was triggered through the parameters passed to it.
Note that the event is triggered after the action event. There is no ability to modify the action through this event.
Please note that, as with all DataTables emitted events, this event is triggered with the dt
namespace. As such, if you use jQuery directly to listen for this event, you must also use the dt
namespace by simply appending .dt
to your event name. This is done automatically if you use the DataTables on()
method.
Type
function( e, buttonApi, dataTable, node, config )
Parameters:
Name | Type | Optional | |
---|---|---|---|
1 | e | No | |
jQuery event object | |||
2 | buttonApi | No | |
DataTables API instance for the selected button - i.e. | |||
3 | dt | No | |
A DataTables API instance for the host DataTable | |||
4 | node | No | |
jQuery instance for the button node that was clicked on | |||
5 | config | No | |
The button's configuration object |
Example
Show a message with the button name that was activated:
var table = new DataTable('#myTable');
table.on('buttons-action', function (e, buttonApi, dataTable, node, config) {
console.log('Button ' + buttonApi.text() + ' was activated');
});