Hi,
I have been trying to implement something in Livewhere, where data can get removed. I have tried this a number of ways, with collections and arrays. But I cannot get it to work properly.
The data will print fine. You can even push data to the collection. If you remove the LAST element, things seem to work just fine. If, however, you remove the first element, weird behavior happens, and the data of the next row gets duplicated into the first row, and then you cannot remove other elements.
I’ve also tried using @entangle and printing out using template x-for, but that produces a different error.
If you remove the last element, it will remove just fine. If, however, you remove another element, the console shows an error that says:
Uncaught (in promise) DOMException: String contains an invalid character
After that, you cannot attempt to remove any other elements.
I am not sure exactly what to do. I have tried this many different ways and am lost as to what’s going on.
I know how I would accomplish this with jQuery and/or AJAX, but that seems to defeat the purpose of using Alpine + Livewire.
Edit: I got it working when using an array, with wire:click. When the code is altered to use @click and then the javascript function does a Livewire.emit, then it no longer works (even when getting the data properly)