It won't work. It might work if you wrap your livewire component inside a blade component, give it a try.
Dynamicly duplicating livewire components in alpine template.
Hi, is there a way to dynamically duplicate livewire components in an alpine template loop?
I have setup similiar to this, an alpine template loop, where positions can be added or removed by alpine:
<template x-for="(position, index) in positions" :key="position.id"> <livewire:media-library wire:model="myUpload" /> </template>
This works fine with other fields inside this template like this:
<input type="hidden" :name="'positions[' + index + '][media_id]'" :value="position.media_id">
But not with the livewire component, because it does not get a unique id. Tried this, but its now working:
<livewire:media-library :wire:key="'media-library-' + index" />
Any idea how to set the wire:key dynamically?
Please or to participate in this conversation.