MediaWiki:Datatables custom.js: Difference between revisions
From Comprehensible Input Wiki
Content added Content deleted
No edit summary |
No edit summary |
||
Line 12: | Line 12: | ||
var waitForDT = setInterval(function () { |
var waitForDT = setInterval(function () { |
||
console.log('in it'); |
console.log('in it'); |
||
if (typeof $('#library').dataTable === 'function' & document.getElementById('tableHolder')) { |
if (typeof $('#library').dataTable === 'function' && document.getElementById('tableHolder')) { |
||
Revision as of 03:51, 7 February 2023
$(document).ready( function () {
document.getElementById('tableHolder').style.display='block';
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
console.log('waiting');
var waitForDT = setInterval(function () {
console.log('in it');
if (typeof $('#library').dataTable === 'function' && document.getElementById('tableHolder')) {
$('#library').dataTable( {
"columnDefs": [
{ "orderData": 4, "targets": 2 }
]
} );
clearInterval(waitForDT);
}
}, 100);
}
});