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

tannk4w's avatar

Duplicate call function. When i call a function in component livewire

I imported a popup component into the layout file, and all pages extend from that layout. Then, I wanted to open that popup from another component that also extends the layout. I used dispatch to trigger the popup. However, I encountered an issue where the save() function gets called twice in a row. I'm not sure why this is happening.

0 likes
4 replies
tannk4w's avatar
tannk4w's avatar

Import to layout

@livewire('student.modal.popup-meeting-company')

extend

<x-student-layout back="/" title="メッセージ" withMenuFooter="true" pageHeader="mess" titleHeader="メッセージ" isHeaderPage="true" :withHeader="true">
    @aware(['isMobile'])
    @livewire('messages.index', ['typeUser' => \App\Enums\UserType::Student->value, 'isMobile' => $isMobile, 'isDisabledPopupMeetingCompany' => $isDisabledPopupMeetingCompany])
</x-student-layout>

and in component i have 1 button to trigger

        public function openPopupMeetingCompany()
    {
        $this->dispatch('refreshPopupMeetingCompany', resetKey: true);
    }
tannk4w's avatar
<div>
    @if ($isOpen)
        <div tabindex="-1" class="flex justify-center items-center fixed inset-0 z-50 bg-black/80">
            <div class="relative p-4 flex items-center w-full justify-center" wire:click.stop>
                <div class="relative rounded-lg border text-card-foreground shadow-2xs w-full max-w-lg max-h-[90vh] overflow-y-auto bg-white">
                    @if ($isShowContentPopup)
                        <button type="button"
                            class="absolute top-2 right-2 text-gray-400 bg-transparent hover:bg-gray-200 hover:text-gray-900 rounded-lg text-sm w-8 h-8 ms-auto inline-flex justify-center items-center dark:hover:bg-gray-600 dark:hover:text-white"
                            wire:click="closeModal()">
tannk4w's avatar

@ghabe I don't know why i cant paste code here. But just a simple button call with wire:click="save" in the popup.

Please or to participate in this conversation.