Am totally lost here. I've made multiple applications with Livewire + AlpineJS + Laravel before, but for some reason I cannot get the @click
functionality working for functions in this app.
I reduced the code to almost nothing and cannot see the issue. Have looked at other apps where I have @click
working.
<div x-data="showAppSettings()">
<div @click="whatever(123)">Click here</div>
<script type="text/javascript">
window.showAppSettings = () => {
return {
showNav: false,
whatever(id)
{
}
};
}
</script>
Upon clicking the click me and triggering the function, I get the error ReferenceError: whatever is not defined.
Works just fine if I do something like @click="alert('hey')"
What am I missing?
The issue was related to including <script src="{{ asset('js/app.js') }}" defer></script>
That file was not even in use. But either way, the error was being triggered by app.js
which I realized made no sense since the code was inline.
Upon removing that line, everything works as intended.