buttons().containers()

Since: Buttons 1.0.0

Get the container elements for one or more button instances. Please note - this property requires the Buttons extension for DataTables.

Description

The buttons method of creating a new button set provides the ability to add only a single set of buttons at a time. However, Buttons has the ability to attach multiple sets of buttons to a single DataTable. This is done by creating additional button sets through the new $.fn.dataTable.Buttons() interface. Once created, the buttons can be accessed via the DataTables API as normal.

This method provides the ability to access the container elements for the button instances that the buttons() selector method selects. The elements can then be inserted into the document anywhere you wish using standard jQuery methods. This method could also be used to move button sets from one location in the document to another (for example using the buttons method and moving the buttons outside of the DataTables controlled DOM).

When using the buttons() selector method, the second argument (the buttons selector) is effectively ignored when processing this method. Only the button instances are used.

Type

function buttons().containers()

Description:

Get a jQuery instance that contains a reference to the button container instances.

Returns:

jQuery instance that contains the container elements for the selected button instances.

Example

Insert buttons which are created using new $.fn.dataTable.Buttons() into the document:

var table = $('#myTable').DataTable();

new $.fn.dataTable.Buttons( table, {
	name: 'commands',
	buttons: ...
} );

table.buttons().containers().appendTo( 'body' );