Catch events in javascript

The docs don’t specify where to put the listener in Javascript, my assumption is the component’s view but it doesn’t work!?

if I put the listener in the view that loads the component everything works fine. Is this intended?

I do it at parent blade component and works well

what do you mean? in the parent component (the view that includes my component) it works for me 2, that’s the issue.

The same code executed inside the component gives me

Uncaught ReferenceError: Livewire is not defined

    <script>
    Livewire.on('change-focus-other-field', function () {
        $("#searchAutocomplete").focus();
    });

</script>

Check in Inspector browser for that script block, remember must be after your @livewireScripts directive

thanks! it quite obvious. JS scripts are all loaded at the end of the page, moving livewire in the header solves the issue

:+1: :partying_face: :partying_face: