I am successfully using HTMX to create and edit content without reloads on my pages (I am following this method: https://blog.benoitblanchon.fr/django-htmx-modal-form/).
For my model, I use django-autocomplete-light to select multiple colors conveniently. This works fine the first time. However, when I close the modal and re-open it (recreate it with an HTMX get request), the multi-select element is shown twice, once how it is not supposed to be shown and once as expected, see screenshot here: https://i.stack.imgur.com/eArEE.png.
I fixed similar JS issues by re-initiating relevant Javascript code with the htmx.onLoad(function(content) { function.
Can you help me understand what I need to put there to re-initiate the django-autocomplete-light element?
Thanks a lot!
Reading your problem seems is coming from a wrong given hx-target. The HTML "partial" you are getting back from the request, it has to be placed in the target of the wrong one. The tutorial you are following is perfect, but it has javascript code to run. Typing javascript it is not what I usually want. I typed some HTMX tutorial and demo, where the mission is to type code without javascript. You can give a look to: www.managepy.it HTMX Demo and Tutorial Page Link