Initial commit
This commit is contained in:
commit
c672ec1666
3 changed files with 295 additions and 0 deletions
52
tests/templates/test.gohtml
Normal file
52
tests/templates/test.gohtml
Normal file
|
@ -0,0 +1,52 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>test</title>
|
||||
<style>
|
||||
form > group{
|
||||
margin: 10px 0;
|
||||
display: block;
|
||||
}
|
||||
group * {
|
||||
display: block;
|
||||
}
|
||||
</style>
|
||||
<script src="/static/serializer.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<form id="testform">
|
||||
{{ range $k, $p := . }}
|
||||
{{ if $p }}
|
||||
<group name="[{{ $k }}]">
|
||||
<input name="name" type="text" value="{{ $p.Name }}">
|
||||
<input name="surname" type="text" value="{{ $p.Surname }}">
|
||||
<input name="age" type="number" value="{{ $p.Age }}">
|
||||
<input name="birth_date" type="date" value="{{ $p.BirthDate.Format "2006-01-02" }}">
|
||||
{{ range $p.Languages }}
|
||||
<group name="[]languages">
|
||||
<input name="language" type="text" value="{{ .Language }}">
|
||||
<input name="skill_level" type="number" value="{{ .SkillLevel }}">
|
||||
</group>
|
||||
{{ end }}
|
||||
</group>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
</form>
|
||||
<script>
|
||||
let f = document.getElementById("testform"),
|
||||
s = new Serializer(f);
|
||||
|
||||
fetch("/", {
|
||||
method: 'post',
|
||||
headers: {
|
||||
'Accept': 'application/json',
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(s.serialize())
|
||||
}).then(() => {
|
||||
window.close()
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Add table
Add a link
Reference in a new issue