debug: aggressive initialization and logging for tomselect

This commit is contained in:
2026-05-01 13:52:33 -04:00
parent 597c11acd1
commit 8e6f4bdcfc
+24 -18
View File
@@ -1,26 +1,32 @@
<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">
<style> <style>
/* Ensure the TomSelect container doesn't get a transparent background */ .ts-control { background-color: #ffffff !important; border: 1px solid #ced4da !important; min-height: 38px !important; }
.ts-control {
background-color: white !important;
border: 1px solid #ddd !important;
}
</style> </style>
<script> <script>
document.addEventListener('DOMContentLoaded', () => { (function() {
document.querySelectorAll('select').forEach((el) => { const init = () => {
if (el.tomselect) return; console.log('TomSelect Initializing...');
const selects = document.querySelectorAll('select');
new TomSelect(el, { console.log('Select count:', selects.length);
create: false, selects.forEach((el) => {
hideSelected: true, if (el.tomselect) return;
maxOptions: null, try {
sortField: { new TomSelect(el, {
field: 'text', create: false,
direction: 'asc' sortField: { field: 'text', direction: 'asc' }
});
console.log('Initialized TomSelect on', el);
} catch(e) {
console.error('TomSelect init error', e);
} }
}); });
}); };
});
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', init);
} else {
init();
}
})();
</script> </script>