New to Livewire 3 and needing to use inline javascripts but its not working.
on my layout.blade.php , i have added stack(‘scripts’)
on my livewire component partial i have added
@push('scripts')
<script>
document.addEventListener('livewire:init', function () {
console.log('loaded');
});
</script>
@endpush
I also tried other events like livewire:initialize, livewire:load, DOMContentLoaded but still doesnt work.
I have been here for a few hours trying to solve this basic inline javascript. can anyone please help me?
2
Answers
I was using laravel livewire 3.1 and for some reason this was the cause of the issue. using
didnt work, it only displayed them in the browser as litereal @script and @endscript words
updating livewire to 3.3 solved this.
For me I did the mistake of putting
@stack('scripts')
in the<body>
ofapp.blade.php
So I had to move it to the
<head>
partThen it started working!