laravel 10 livewire 3 I'm facing error in wire:navigate js file not loading. tried below code and followed documentation. still not solved
https://livewire.laravel.com/docs/navigate
I tried below code
app.blade.php
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{ $title ?? 'Page Title' }}</title>
</head>
<body>
{{ $slot }}
</body>
<script>
document.addEventListener('livewire:navigated', () => {
<script src="/vendor/fancybox/fancybox.js" ></script>
<script src="/vendor/gsap/gsap.min.js" ></script>
<script src="/js/script.js" ></script>
})
</script>
</html>
And Also Tried Below Code too
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{ $title ?? 'Page Title' }}</title>
</head>
<body>
{{ $slot }}
</body>
<script src="/vendor/fancybox/fancybox.js" data-navigate-track></script>
<script src="/vendor/gsap/gsap.min.js" data-navigate-track></script>
<script src="/js/script.js" data-navigate-track></script>
</html>
You are putting your scripts after the body which is an unusual practice (if not downright a bad practice).
The conventional places where to puts scripts are the head and the body and Livewire can manage scripts placed in that positions.
You can use data-navigate-track when the scripts are set in the head and to force the page reload if needed.
livewire:navigation is not useful in this situation.