flowbite icon indicating copy to clipboard operation
flowbite copied to clipboard

Closing a Modal whose close button is in an HTML content located elsewhere inserted into the DOM via HTMX

Open anjanesh opened this issue 2 years ago • 0 comments

<form hx-post="{% url 'my_nice_url' %}" hx-target="this" hx-swap="innerHTML">
    {% include "../partials/some-form.html" %}
</form>

In some-form.html I have :

<div>
    <button type="submit">Update</button>
    <button data-modal-hide="modal-myModal" type="button">Close</button>
</div>

If I click the update button, I'll get the confirmation displayed via HTMX and it contains a close button - close button being :

<button data-modal-hide="modal-myModal" type="button">Close</button>

But clicking on the close button on form POST doesn't close the form.

Is this because the button is located in a file elsewhere which get updated into the DOM via HTMX ?

anjanesh avatar Jul 21 '23 06:07 anjanesh