File: off%28%29.xml

package info (click to toggle)
datatables.js 1.11.5%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 22,848 kB
  • sloc: javascript: 65,075; xml: 10,712; php: 4,741; sh: 544; makefile: 18
file content (47 lines) | stat: -rw-r--r-- 2,121 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?xml version="1.0" encoding="UTF-8" ?>
<dt-api group="core">
	<name>off()</name>
	<summary>Table events removal.</summary>
	<since>1.10</since>

	<type type="function">
		<signature>off( event [, callback] )</signature>
		<description>Remove event listeners that have previously been added with `dt-api on()`.</description>
		<parameter type="string" name="event">
			Event name to remove. Multiple events can be removed by using a space separator or namespacing, just as with `jQuery().off()`.
		</parameter>
		<parameter type="function" name="callback" default="">
			Specific callback function to remove if you want to unbind a single event listener. If not given, all events which match the event name / namespace given in the first parameter will be removed.
		</parameter>
		<returns type="DataTables.Api">DataTables API instance</returns>
	</type>

	<description>
		DataTables can trigger a number of events which can be useful for taking action when DataTables performs those events. For example, it is often useful to know when an Ajax event occurs (`dt-event xhr`), so you can add additional data to the JSON payload.

		DataTables provides three methods for working with DataTables events, matching the core jQuery event methods:

		* `dt-api on()` - Listen for events
		* `dt-api off()` - Stop listening for events
		* `dt-api one()` - Listen for a single event.

		This `dt-api off()` method is used to remove a listener that has already been attached to a DataTable. Simply pass in the event you wish to remove the listener for, and optionally the specific function if you want to remove only a single event listener.
	</description>

	<example title="Listen for only the first `dt-event xhr` event from DataTables"><![CDATA[
var table = $('#example').DataTable( {
	ajax: "/data",
	serverSide: true
} );

table.on( 'xhr', function ( e, settings, json ) {
	table.off( 'xhr' );
	console.log( 'Ajax event occurred. Returned data: ', json );
} );

// note that this is the same effect as using `table.one(...);`
]]></example>

	<related type="api">on()</related>
	<related type="api">one()</related>
</dt-api>