MediaWiki:Datatables custom.js: Difference between revisions
From Comprehensible Input Wiki
Content added Content deleted
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
$(document).ready( function () { |
$(document).ready( function () { |
||
if(document.getElementById('library')){ |
|||
⚫ | |||
// Create <thead> for DataTables to work |
// Create <thead> for DataTables to work |
||
var header = document.getElementById('library').createTHead().id = 'lib-thead'; |
var header = document.getElementById('library').createTHead().id = 'lib-thead'; |
||
jQuery('#lib-header').detach().appendTo('#lib-thead'); |
jQuery('#lib-header').detach().appendTo('#lib-thead'); |
||
document.getElementById('tableHolder').style.display='block'; |
document.getElementById('tableHolder').style.display='block'; |
||
// Activate DataTable |
// Activate DataTable |
||
var waitForDT = setInterval(function () { |
var waitForDT = setInterval(function () { |
||
if (typeof $('#library').dataTable === 'function' & document.getElementById('tableHolder')) { |
if (typeof $('#library').dataTable === 'function' & document.getElementById('tableHolder')) { |
||
$('#library').dataTable( { |
$('#library').dataTable( { |
||
"columnDefs": [ |
"columnDefs": [ |
||
{ "orderData": 4, "targets": 2 } |
{ "orderData": 4, "targets": 2 } |
||
] |
] |
||
} ); |
} ); |
||
clearInterval(waitForDT); |
clearInterval(waitForDT); |
||
} |
} |
||
}, 100); |
}, 100); |
||
⚫ | |||
}); |
}); |
Revision as of 03:00, 7 February 2023
$(document).ready( function () {
if(document.getElementById('library')){
// Create <thead> for DataTables to work
var header = document.getElementById('library').createTHead().id = 'lib-thead';
jQuery('#lib-header').detach().appendTo('#lib-thead');
document.getElementById('tableHolder').style.display='block';
// Activate DataTable
var waitForDT = setInterval(function () {
if (typeof $('#library').dataTable === 'function' & document.getElementById('tableHolder')) {
$('#library').dataTable( {
"columnDefs": [
{ "orderData": 4, "targets": 2 }
]
} );
clearInterval(waitForDT);
}
}, 100);
}
});