bigskysoftware / htmx

</> htmx - high power tools for HTML
https://htmx.org
Other
37.43k stars 1.26k forks source link

hx-post does not trigger submit event of form #396

Closed BoPeng closed 3 years ago

BoPeng commented 3 years ago

I have a form with a textarea that is edited by easymde.js. The idea is that the textarea is hidden and replaced by a bunch of codemirror stuff,

<form>
<hidden textarea>
<js-created codemirror editor>
<button type='submit'>submit</button>
</form>

The trick here is that the content of the textarea will be replaced by the content of the editor when the submit event of the form is triggered.

However, when the form is triggered by hx-post, the form element no longer emits a submit event (at least according to my addEventListener test code) so the textarea will always be empty when the form is submitted.

I think this should be fixed if confirmed.

1cg commented 3 years ago

Hi Bo,

This sounds like a library conflict, where both easymde and htmx are fighting over the submit action.

Does easymde fire any events after it has updated the text area that you can catch with an hx-trigger? That might be a good solution.