Hello
I have trouble with scripts that initialize functionalities like select2 or datatables where i get a bug on my laravel project with livewire.
I have setup the datatables script like this for example:
<script>
new DataTable('#usersTable', {
responsive: true,
language: {
url: "{{ __('messages.tablesLang') }}",
paginate: {
"first": "«",
"last": '\u203A',
"next": "»",
"previous": '\u2039'
},
}
});
</script>
or select2 like this
<script>
$(document).ready(function() {
$('.create-user').select2({
width: 'resolve'
});
});
</script>
they work just fine, but i have like more than 1 route where i use the data tables and when i go to for example users which has datatables, and than i go to dashboard route and click back (to users route) the data tables have double everything initialized (paging, filters and all other options) or the select2 doubles its selects.
I just want to know if this is a general livewire problem where navigating back to a route that has some external stuff initialized they get doubled.
Cause i know what causes it, its wire:navigate that i put on links when navigating to other routes.
If i remove it, it works fine but than the project doesnt have the SPA feeling anymore.
Is there a workaround on how to use scripts with livewire.
Thank you for your understanding.