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,
0:03 I want to search again for apple.
0:05 Cool. That's nice. What about wwdc.
0:07 Got those two results there.
0:09 Those are fantastic. What about indy and maybe EVs.
0:14 Oh what was that second one I searched for?
0:16 I'll just hit the back button.
0:17 Wait where'd search go? What just happened?
0:20 I feel like I did a bunch of things and then the browser temporarily decided they
0:24 weren't relevant for my history, and it just ignored them.
0:28 And now I jumped back like five actions in my web browser.
0:32 Wouldn't it be cool if we could put those in our browser history and put them
0:36 in the URL?
0:38 Turns out that we can it's actually super simple.
0:41 So down here we can say
0:42 hx-push-url="true"
0:45 That's it. Come back here, refresh.
0:51 Go to our search. Let's search for apple.
0:54 Look at the URL, search question mark.
0:57 search_text equals apple. What about indy?
1:01 What about EVs? Okay. Same thing as before.
1:05 I want to go back and see what I just searched for, back.
1:08 there's indy, there's apple. I wanna go forward again.
1:11 Indy, there's the EVs. Oh my goodness,
1:15 look at that. That was all we had to do there.
1:20 That was it. Now, while this is amazing, and I really, really like this feature,
1:26 it leads to a challenge. Now that this is up in the URL.
1:29 Guess what? I might want to bookmark it.
1:33 I might want to share it with somebody.
1:35 I might want to just come back to it.
1:37 So if I go away, and I come back and I hit this uh sigh.
1:43 Not so amazing. Remember we talked about deep linking, that is our application behaves like
1:50 a website, not a crappy SPA that doesn't understand that you can link to things.
1:54 So right now it is one of those crappy spots.
1:57 Unfortunately those single page app type of experiences.
2:00 But we're going to add it,
2:02 we're gonna add this functionality to support deep linking as well.
2:05 But already the ability to go over here and search for like car, have that show
2:10 up and go in our history.
2:12 It's a huge step especially given
2:14 that we typed what, 12,
2:16 15 characters to make it happen.
2:18 Yeah, it was totally worth it.