You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I started to use HTMX in my Django site.
HTMX is guite often used with lazy loading with paginated querysets.
This leads to fact that the first page has the Jquery, and as the lazy loaded objects are insterted into DOM the event listeners are not added. (Or atleast I could get them working)
The solution for me was to make django-likes to work with HTMX. Changes are quite small and remove totally depency to JQuery - which I suppose is good. :-)
I tried to keep the changes at minimum and I am sure that with further work the implementation could be nicer.
I started to use HTMX in my Django site.
HTMX is guite often used with lazy loading with paginated querysets.
This leads to fact that the first page has the Jquery, and as the lazy loaded objects are insterted into DOM the event listeners are not added. (Or atleast I could get them working)
The solution for me was to make django-likes to work with HTMX. Changes are quite small and remove totally depency to JQuery - which I suppose is good. :-)
I tried to keep the changes at minimum and I am sure that with further work the implementation could be nicer.
as example the button.html is changed to:
and add_or_remove in views is changed to
And likes.js is removed.
<script src="https://unpkg.com/[email protected]"></script>And htmx needs to be included in the base.html (or on page-by-page basis)
rest is untouched! :-)
Quite small changes and JQuery is gone!
Should I make a PR on this?
The text was updated successfully, but these errors were encountered: