It looks like you're trying to implement a popover using Alpine.js and Livewire, but the popover panel is not displaying when the button is clicked. This could be due to a few reasons, such as missing Alpine.js directives or incorrect usage of the x-popover directives.
Here are a few steps to troubleshoot and potentially fix the issue:
-
Ensure Alpine.js is Loaded: Make sure that Alpine.js is properly included in your project. You can add it via a CDN in your main layout file:
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/cdn.min.js" defer></script> -
Check Alpine.js Directives: Ensure that the Alpine.js directives are correctly applied. The
x-popover:buttonandx-popover:paneldirectives should be properly recognized by Alpine.js. -
Use x-data and x-show: Instead of relying on custom
x-popoverdirectives, you can usex-dataandx-showto control the visibility of the popover panel. Here is a modified version of your code:// schools.blade.php <div x-data="{ open: false }" class="relative"> <div> <button @click="open = !open" class="flex items-center gap-2 rounded-lg border pl-3 pr-2 py-1 text-gray-600 text-sm"> <div>Filter</div> <x-heroicons.chevronDown/> </button> </div> <div x-show="open" @click.away="open = false" class="absolute left-0 mt-2 bg-white rounded-md border border-gray-100 shadow-xl z-10 w-64 overflow-hidden"> <div class="flex flex-col divide-y divide-gray-100"> @foreach ($filters->schools() as $school) <label class="flex items-center px-3 py-2 gap-2 cursor-pointer hover:bg-gray-100"> <input value="{{ $school->id }}" wire:model.live="filters.selectedProductIds" type="checkbox" class="rounded border-gray-300"> <div class="text-sm text-gray-800">{{ $school->name }}</div> </label> @endforeach </div> </div> </div> -
Ensure Livewire is Working: Make sure that Livewire is properly set up and working in your project. You should have the Livewire scripts included in your main layout file:
@livewireStyles @livewireScripts -
Check for Errors: Open your browser's developer console and check for any JavaScript errors that might indicate what is going wrong.
By following these steps, you should be able to get the popover functionality working correctly. If the issue persists, please provide more details or any error messages you are seeing.