HTMX + Flask: Modern Python Web Apps, Hold the JavaScript Transcripts
Chapter: Feature 2: Active search
Lecture: Search history in the address bar

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Well let's do some more searching. Over here, I want to search again for apple. Cool. That's nice. What about wwdc. Got those two results there.
0:10 Those are fantastic. What about indy and maybe EVs. Oh what was that second one I searched for? I'll just hit the back button.
0:18 Wait where'd search go? What just happened? I feel like I did a bunch of things and then the browser temporarily decided they
0:25 weren't relevant for my history, and it just ignored them. And now I jumped back like five actions in my web browser.
0:33 Wouldn't it be cool if we could put those in our browser history and put them in the URL? Turns out that we can it's actually super simple.
0:42 So down here we can say hx-push-url="true" That's it. Come back here, refresh. Go to our search. Let's search for apple.
0:55 Look at the URL, search question mark. search_text equals apple. What about indy? What about EVs? Okay. Same thing as before.
1:06 I want to go back and see what I just searched for, back. there's indy, there's apple. I wanna go forward again. Indy, there's the EVs. Oh my goodness,
1:16 look at that. That was all we had to do there. That was it. Now, while this is amazing, and I really, really like this feature,
1:27 it leads to a challenge. Now that this is up in the URL. Guess what? I might want to bookmark it. I might want to share it with somebody.
1:36 I might want to just come back to it. So if I go away, and I come back and I hit this sigh.
1:44 Not so amazing. Remember we talked about deep linking, that is our application behaves like
1:51 a website, not a crappy SPA that doesn't understand that you can link to things. So right now it is one of those crappy spots.
1:58 Unfortunately those single page app type of experiences. But we're going to add it, we're gonna add this functionality to support deep linking as well.
2:06 But already the ability to go over here and search for like car, have that show up and go in our history. It's a huge step especially given
2:15 that we typed what, 12, 15 characters to make it happen. Yeah, it was totally worth it.


Talk Python's Mastodon Michael Kennedy's Mastodon