imacrayon / alpine-ajax

An Alpine.js plugin for building server-powered frontends.
https://alpine-ajax.js.org
MIT License
558 stars 11 forks source link

`MissingIdError` error thrown when using `x-target.replace` without an ID #53

Closed jannbar closed 7 months ago

jannbar commented 7 months ago

Hey @imacrayon,

thank you for all the work you put into this plugin! Really appreciate it!

I found a small bug – I have a form that looks like this:

<form x-init x-target="customer-table" x-target.replace></form>

Everything works as expected, but I get this error in the console:

Uncaught Missing ID: <form x-init="" x-target="customer-table" x-target.replace=""> is missing an ID to target.

When I add an id to the form, the error disappears. If the ID is required, the docs should probably tell this – but I don't think it's required, because everything works? πŸ€”

Maybe you can have a look.

TIA & Greetings from Germany!

imacrayon commented 7 months ago

Hi! Instead of using multiple x-targets on the element, x-target.replace="customer-table” should work. I should have provided a more complete example in the docs, so thanks for reaching out.

jannbar commented 7 months ago

Ah that makes sense – thank you!