I have a Bootstrap selectpicker element that works fine on the first render. It's initialized with:
$(document).ready(function () {
$('select').selectpicker();
});
But after livewire's render function is called the <select> element is not rendered as Bootstrap selectpicker anymore.
Going through both the docs (relevant sections here and here), I figured that the code below should fix it:
<script>
document.addEventListener("livewire:load", function(event) {
window.livewire.hook('afterDomUpdate', () => {
$('select').selectpicker('refresh');
});
});
</script>
But this doesn't work. I've also tried:
$('select').selectpicker();
and
$('select').selectpicker('render');
both within afterDomUpdate, that doesn't work as well. If I call all these functions from the console the DOM doesn't update the <select> element, so indeed these functions do not seem to work.