Fixing the URLs
The HTMX
package makes asynchronous HTTP requests to the web service and displays the results, which is an effective way to create a responsible application, but the result doesn’t behave correctly. To see the problem, navigate to http://localhost:5000/admin
, click the Orders button, and then click the browser’s reload button. Instead of reloading the Orders table, the products are displayed, as shown in Figure 20.8.
Figure 20.8: Reloading the browser
The browser isn’t aware of the effect of user interaction, and reloading effectively resets the client, which displays the product table. To fix this means defining a set of routes that allow direct navigation to specific application features, as well as configuring HTMX
to add URLs that will target those routes following user interaction. Listing 20.41 defines the routes required to navigate directly to the products table, the orders table, and the editor for a specific product.