I am using livewire 3. I have a button inside a component and i want to delete the component with that button which is also inside the component.
InvoiceRow component:
<div class="col-md-1">
<button wire:click="confirmDelete" class="btn btn-danger"><i class="fa fa-trash"></i> Delete</button>
</div>
public function confirmDelete()
{
$this->dispatch('deleteRow');
}
CreateInvoice component:
#[On('post-created')]
public function deleteRow(){
// i want to know what to do here so i can delete the component??
}
<div class="mt-5">
@foreach (range(0, $rowCount - 1) as $index)
@livewire('invoice-row', ['index' => $index], key($index))
@endforeach
<br>
<button type="button" wire:click="increaseRowCount" name="addRow" class="btn btn-success float-right">Add New Row</button>
</div>
i want it to add the component on add new row button which is working fine but now i want a delete button which is present inside the component itself so how to achieve it.