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

ReyXt's avatar
Level 1

wire:click not working

hai, do u guys have any idea why my wire:cllick not working?

here is my code :

Function :

public function exportToPDF()
    {
        
        $selectedIds = $this->checkedValues();

        if (empty($selectedIds)) {
            $this->dispatchBrowserEvent('showToast', ['success' => false, 'message' => 'Pilih data yang ingin diekspor terlebih dahulu.']);
            return;
        }
        
        $selectedData = User::with('bidang', 'role')
        ->whereIn('id', $this->checkedValues())
        ->get();
        
        $pdf = Pdf::loadView('exports.InternPdf', compact('selectedData'))
        ->setPaper('a4', 'portrait');

        return response()->streamDownload(
            fn() => print($pdf->output()),
            'PesertaMagang.pdf'
    );
    }

Button :

<div class="btn-group">
        <button type="button" class="btn btn-primary dropdown-toggle mb" data-bs-toggle="dropdown" 										 aria-expanded="false">
            Export
        </button>
        <ul class="dropdown-menu">
            <li><a class="dropdown-item" wire:click="exportToExcel">Export ke Excel</a></li>
            <li><a class="dropdown-item" wire:click="exportToPDF">Export ke PDF</a></li>
        </ul>
    </div>
1 like
7 replies
Snapey's avatar

check for errors in the browser console

Snapey's avatar

@ReyXt console error when you click? Network request when you click?

ReyXt's avatar
Level 1

@Snapey actualy the problem is when i click the button there is literaly nothing happen

Snapey's avatar

@ReyXt The blade you showed is INSIDE your livewire view? In the browser source, look for the component root div and make sure you can see wire attributes on it.

ReyXt's avatar
Level 1

@Snapey oh ya, thats the problem, i use wire click outside livewire view, but is there any way to use wire click outside livewire view?btw thanks for the help

Please or to participate in this conversation.