News for hackers. Stuff that matters.
Re:Django, HTMX and Alpine.js: Modern websites, JavaScript o... by mcny on Wednesday November 24, 2021 @04:57AM (#29328470)
Thank you. To continue this conversation, how would one implement searching and filtering? My use case is an online ecommerce store (think amazon.com or newegg) where you sell multiple different categories of items. For example, if someone searches for SSD, we should show a list of checkboxes to filter by capacity such as 1 GB or below, up to 127GB, ... (based on inventory and other business requirements). How would I do that?

In your example, we can say something like if you could grab lists of by contacts by some common trait such as employer or domain of email address?

Re:Django, HTMX and Alpine.js: Modern websites, JavaScript o... by yawaramin on Saturday November 27, 2021 @01:02AM (#29357879)
You'd have category pages with different filters. E.g. for the 'Storage' category you'd have, among others, the 'capacity' filter. HTMX doesn't take over your entire render like a SPA. It affects targeted areas of the page. E.g. when you would select the '<1GB' checkbox and click 'Filter' on the left panel, that's where HTMX would step in, to swap in the response of calling the 'search' endpoint with the current filter params, e.g. '/search/storage?capacity=<1GB'.