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
|
function initDatatable(){
if (window.ArchivesDataTables.length === 0 && $('.archives-data-table').length !== 0) {
$('.archives-data-table').each((_, element) => {
var table = $(element).DataTable( {
"order": [[ 0, "desc" ]],
"paging": true,
"ordering": true,
"searching": true,
"info": true,
"lengthChange": false,
"language": {
"emptyTable": "Currently there are no GLSAs available. -- Start with releasing one."
},
"columnDefs": [
{
"targets": 'hide',
"visible": false
}],
});
window.ArchivesDataTables.push(table);
// Add event listener for opening and closing details
$('#table_id tbody').on('click', 'td', function () {
var tr = $(this).closest('tr');
var row = table.row( tr );
Turbolinks.visit("/glsa/" + row.data()[0]);
} );
});
}
}
function destroyDatatable(){
while (window.ArchivesDataTables.length !== 0) {
window.ArchivesDataTables.pop().destroy();
}
}
export default {initDatatable, destroyDatatable}
|