How to fix Bootstrap 5 Dropdown didnt work after wire:navigate page? #7513
Unanswered
ilhamprabuzakys
asked this question in
1. Help
Replies: 2 comments 10 replies
-
Add
|
Beta Was this translation helpful? Give feedback.
10 replies
-
You can wrap the heading using the @persist tag, like: @persist('nav')
<!-- Your nav code here -->
@endpersist This way, it will only be rendered once across all renders when using |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
2023-12-12.08-59-20.mp4
I've bootstrap 5 navbar and on the menu item there's dropdown element. It's work on the initial load.
But after I navigate to other page and click the dropdown again.
The dropdown stopped working. I need to navigate to another page, and click it again to make it work.
I'm using Livewire 3 and Laravel 10.
I've done some research that said I need to reinitialize Bootstrap after navigating with Livewire.
Like this :
`document.addEventListener('livewire:navigated', () => {
console.log('Livewire navigated.');
initDropdown();
});
function initDropdown() {
try {
let myDropdown = document.querySelector('#dropdown-indeks');
new bootstrap.Dropdown(myDropdown);
console.log('initDropdown');
} catch (error) {
console.error('Theres some error:', error);
}
}`
But unfortunately it didnt work at all. Please help me guys
Beta Was this translation helpful? Give feedback.
All reactions