fix: use @push('js') to correctly inject tomselect script into Tablar layout

This commit is contained in:
2026-05-01 12:59:21 -04:00
parent 1f4b108c51
commit bb71e41459
+3 -10
View File
@@ -1,14 +1,9 @@
@push('js')
<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>
document.addEventListener('DOMContentLoaded', () => { document.addEventListener('DOMContentLoaded', () => {
console.log('DOM fully loaded, searching for selects...'); document.querySelectorAll('select').forEach((el) => {
const selects = document.querySelectorAll('select');
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: {
@@ -16,9 +11,7 @@
direction: 'asc' direction: 'asc'
} }
}); });
} catch (e) {
console.error('TomSelect failed for:', el, e);
}
}); });
}); });
</script> </script>
@endpush