Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Eloïse's avatar

wire:confirm not working on checkbox

Hello, I would have a confirm dialog when checking a checkbox, I tried this but the dialog does not appear

<input type="checkbox" wire:model.live="trackingClosed" wire:confirm="Êtes-vous sûr(e) de vouloir clôturer ce suivi ?" >

Thanks for your help

0 likes
4 replies
tykus's avatar

There is no action on the checkbox; e.g. there is no wire:click directive, so nothing to trigger.

Eloïse's avatar

ok, I got a dialog box but if i click cancel the action is performed. there is nos solution to perform this ? I tried with alpine and not better

tykus's avatar

@Eloïse can you share what you have done to get the dialog?

Eloïse's avatar

Sure ! :)

<div wire:key="{{ $tracking_id }}" x-data="{tracking_closed: @entangle('trackingClosed') }">
    @can(\App\enums\PermissionsEnum::CLOSE_VEHICLE_TRACKING->value)
        {{-- pinkTrackingOpen --}}
        <div class="flex">
            <div class="mr-2">
                <input x-bind:disabled="tracking_closed"
                       x-bind:readonly="tracking_closed"
                       type="checkbox"
                       wire:model.live="trackingClosed"
                       x-bind:checked="tracking_closed"
                       
                       wire:click="closeTracking"
                       wire:confirm="Êtes-vous sûr(e) de vouloir clôturer ce suivi ?" >
            </div>
            <div>
                <span
                    x-bind:class="tracking_closed ? 'italic text-gray-400': ''"
                    x-text="tracking_closed ? 'Clôturée le {{ $tracking->locked_at?->format('d-m-Y') }}' : 'Clôturer la fiche'"></span>
            </div>
        </div>
    @endcan
</div>

Please or to participate in this conversation.