forked from TFMM/silent-auction
debug: add verbose logging to tomselect init
This commit is contained in:
@@ -1,17 +1,23 @@
|
|||||||
<script src="https://cdn.jsdelivr.net/npm/tom-select@2.4.3/dist/js/tom-select.complete.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/tom-select@2.4.3/dist/js/tom-select.complete.min.js"></script>
|
||||||
<link href="https://cdn.jsdelivr.net/npm/tom-select@2.4.3/dist/css/tom-select.bootstrap5.min.css" rel="stylesheet">
|
<link href="https://cdn.jsdelivr.net/npm/tom-select@2.4.3/dist/css/tom-select.bootstrap5.min.css" rel="stylesheet">
|
||||||
<script>
|
<script>
|
||||||
window.addEventListener('load', () => {
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
document.querySelectorAll('select').forEach((el) => {
|
console.log('DOM fully loaded, searching for selects...');
|
||||||
if (!el.classList.contains('ts-hidden-accessible')) {
|
const selects = document.querySelectorAll('select');
|
||||||
console.log('Initializing TomSelect on:', el);
|
console.log('Found ' + selects.length + ' select elements.');
|
||||||
|
|
||||||
|
selects.forEach((el) => {
|
||||||
|
console.log('Attaching TomSelect to:', el);
|
||||||
|
try {
|
||||||
new TomSelect(el, {
|
new TomSelect(el, {
|
||||||
create: false,
|
create: false,
|
||||||
sortField: {
|
sortField: {
|
||||||
field: "text",
|
field: 'text',
|
||||||
direction: "asc"
|
direction: 'asc'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
} catch (e) {
|
||||||
|
console.error('TomSelect failed for:', el, e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user