Dosmukhanbet
5 months ago
820
3
Laravel

Livewire wire:click doesn't trigger action inside of foreach

Posted 5 months ago by Dosmukhanbet

hello! Please help me with following issue, Livewire wire:click doesn't trigger action inside of foreach, it just submit form despite that i prevent submit form but outside of foreach works fine.

the livewire view code:

    <div>
        <input type="text" wire:model="search"  placeholder="Start typing materials name"
        class="border border-gray-400 hover:border-gray-500 px-4 py-2 pr-8 rounded shadow leading-tight "
        >
    </div>
    
    @foreach ($searchResults as $material)
        <div>
            {{ $material['name'] }} <button wire:click="addMaterialToRequest({{ $material['name'] }})">Add to request</button>
        </div>
    @endforeach


    <a href="#" wire:click="addMaterialToRequest('hello')">Add to request</a>
    <button type="submit" wire:click="submit">Submit Requisition</button>
</form>

Please sign in or create an account to participate in this conversation.