{hero}

stateLoaded

Since: DataTables 1.10

State loaded event - fired once state has been loaded and applied.

Description

The stateLoaded event differs from the stateLoadParams in that it is fired after the state has been loaded and applied to the table (internally - the effects will not yet have been drawn onto the page upon execution of this event). This this case, the state object cannot be modified, while with stateLoadParams it can be. This event is usual for custom or plug-in parameters being loaded and applied from the state storage.

The stateLoaded event is the event compliment of the stateLoaded callback initialisation option. The event is fired at the same time as the callback (technically the callback fires before the event, but they occur sequentially and thus either can be used to achieve the same effect).

Please note that, as with all DataTables emitted events, the event object has a DataTables API instance available on it (the first parameter). Additionally, the events are triggered with the dt namespace. As such, to listen for this event, you must also use the dt namespace by simply appending .dt to your event name, as shown in the example below.

Type

function function( e, settings, json )

Parameters:

Example

Show custom saved data in an input element:

$('#example')
	.on('stateLoaded.dt', function (e, settings, data) {
		$('#myInput').val(data.myCustomValue);
	})
	.DataTable();

Related

The following options are directly related and may also be useful in your application development.