The issue you're encountering is related to the use of wire:show and x-show in Livewire. These directives are not native to Livewire and are likely being confused with Alpine.js's x-show. Livewire does not have a wire:show directive, which means that the conditional rendering logic you're trying to apply won't work as expected.
Here's a solution to achieve the desired behavior using Livewire's native features:
-
Use
wire:iforwire:keyfor Conditional Rendering:Instead of using
wire:show, you can conditionally render the component using@ifin Blade orwire:keyto ensure the component is re-rendered when the condition changes. -
Use Alpine.js for Conditional Display:
If you want to conditionally show/hide elements on the client side without re-rendering, you can use Alpine.js's
x-showdirective. Ensure Alpine.js is included in your project.
Here's how you can modify your code:
<div class="col-md-4 text-end" x-data="{ isAuthorizedVisible: @entangle('form.isAuthorizedVisible') }">
<div x-show="isAuthorizedVisible">
<select id="manivox_numbers" wire:model="form.numbers" class="form-select" multiple></select>
<select id="manivox_numbers_ds" class="form-select" style="display: none;"></select>
<livewire:manage-cli wire:model="form.numbers" lazy/>
</div>
</div>
Explanation:
-
x-dataandx-show: This uses Alpine.js to manage the visibility of the element. Thex-datadirective initializes a local Alpine.js component state, andx-showconditionally displays the element based on theisAuthorizedVisibleproperty. -
@entangle: This directive is used to bind Livewire properties to Alpine.js, allowing them to stay in sync.
By using Alpine.js for the client-side visibility and Livewire for server-side data binding, you can achieve the desired behavior without running into issues with non-existent Livewire directives. Make sure Alpine.js is included in your project for this to work.