themesberg / flowbite

Open-source UI component library and front-end development framework based on Tailwind CSS
https://flowbite.com
MIT License
7.61k stars 715 forks source link

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

Open anjanesh opened 1 year ago

anjanesh commented 1 year ago
<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 ?