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

Can't self target on `<form>` when it has `x-merge` #41

Closed DrSensor closed 8 months ago

DrSensor commented 9 months ago

I found out x-target cannot be blank (self-target) on <form> when there is x-merge. For example:

<form id=user x-init x-target x-merge=after method=post action=/create/users>
  <button>Create</button> <!-- Uncaught (in promise) Missing Target: #[object HTMLInputElement] was not found in the current document. -->
</form>

Is this intentional?

(I've not yet test for other x-merge pattern)

imacrayon commented 9 months ago

Nope, not intentional. Thanks for reporting this!

imacrayon commented 9 months ago

@DrSensor I tried reproducing the issue here: https://codepen.io/imacrayon/pen/vYbqqob I seems to be working though. Could it be that the content you are appending doesn't have a container with id=user?

DrSensor commented 8 months ago

Now I'm not sure what is happening. I will reopen this when I can reproduce it (need to grok my commit history 😂)