Do search if querystring is provided

This commit is contained in:
Jake Howard 2022-08-01 21:23:55 +01:00
parent fb78f3f993
commit 93030852b5
Signed by: jake
GPG key ID: 57AFB45680EDD477
2 changed files with 3 additions and 1 deletions

View file

@ -43,6 +43,7 @@ class SearchPage(BaseContentMixin, RoutablePageMixin, BasePage): # type: ignore
def get_context(self, request: HttpRequest) -> dict: def get_context(self, request: HttpRequest) -> dict:
context = super().get_context(request) context = super().get_context(request)
context["search_query"] = request.GET.get("q", "")
context["search_url"] = self.reverse_subpage("results") context["search_url"] = self.reverse_subpage("results")
return context return context

View file

@ -16,9 +16,10 @@
name="q" name="q"
placeholder="Search" placeholder="Search"
hx-get="{{ search_url }}" hx-get="{{ search_url }}"
hx-trigger="keyup changed delay:300ms, search" hx-trigger="keyup changed delay:300ms, search, revealed"
hx-target="#search-results" hx-target="#search-results"
autocomplete="off" autocomplete="off"
value="{{ search_query }}"
> >
</section> </section>