generated from ElnuDev/go-project
Better API handling
This commit is contained in:
parent
61c1ce5502
commit
f558d7f0c1
4 changed files with 62 additions and 52 deletions
|
@ -3,7 +3,7 @@
|
|||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>jidict</title>
|
||||
<title>{{ with .Query }}{{ . }} search - {{ end }}jidict</title>
|
||||
<link rel="stylesheet" href="https://unpkg.com/missing.css@1.0.9/dist/missing.min.css">
|
||||
<style>
|
||||
li {
|
||||
|
@ -18,14 +18,13 @@
|
|||
<img src="https://jichan.org/logo.svg" style="height: 4em; display: block; margin: 1em auto 1em auto">
|
||||
</a>
|
||||
<form
|
||||
hx-get="/api/search"
|
||||
hx-on::before-request="this.setAttribute('hx-replace-url', `/search/${this.querySelector('input').value}`)"
|
||||
hx-target="#results"
|
||||
hx-swap="innerHTML">
|
||||
hx-get="/search"
|
||||
hx-replace-url="true"
|
||||
hx-target="#results">
|
||||
<input type="text" name="q"{{ with .Query }} value="{{ . }}"{{ end }} placeholder="辞書をサーチする" class="width:100%" autocomplete="false">
|
||||
</form>
|
||||
<div id="results">
|
||||
{{ with .Results }}{{ template "search" . }}{{ end }}
|
||||
{{ if .Count }}{{ template "search" . }}{{ end }}
|
||||
</div>
|
||||
<br>
|
||||
</main>
|
||||
|
|
Reference in a new issue