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 48 49 50 51 52 53 54
|
<?xml version="1.0" encoding="UTF-8" ?>
<dt-type group="js">
<name>function</name>
<summary>Javascript `Function`</summary>
<description>
<.
## Use in DataTables
Where a parameter is shown as accepting a function type, or a method returning a function type, it indicates that a function can be passed in (be it as a function assigned to a variable, or an anonymous function) / returned.
Functions in DataTables are frequently used for callbacks. For example, using an anonymous function which is executed whenever DataTables performs a draw action (`dt-init drawCallback`):
```js
$('#example').DataTable( {
drawCallback: function () {
console.log( 'Table redrawn '+new Date() );
}
} );
```
Same example assigning the function to a variable:
```js
var draw = function () {
console.log( 'Table redrawn '+new Date() );
};
$('#example').DataTable( {
drawCallback: draw
} );
```
And finally, the same example using a named function:
```js
function draw () {
console.log( 'Table redrawn '+new Date() );
};
$('#example').DataTable( {
drawCallback: draw
} );
```
]]>
</description>
</dt-type>
|