Fix the typeahead
This commit is contained in:
parent
a40b5ac534
commit
0c2e35bb80
2 changed files with 6 additions and 9 deletions
|
@ -10,6 +10,7 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"net/http"
|
"net/http"
|
||||||
"path"
|
"path"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"gitlab.com/trantor/trantor/lib/database"
|
"gitlab.com/trantor/trantor/lib/database"
|
||||||
|
@ -57,7 +58,9 @@ func InitTemplate(assetsPath string) *Template {
|
||||||
var t Template
|
var t Template
|
||||||
templatePath := path.Join(assetsPath, "templates")
|
templatePath := path.Join(assetsPath, "templates")
|
||||||
|
|
||||||
t.html, err = html_tmpl.ParseGlob(path.Join(templatePath, "*.html"))
|
t.html, err = html_tmpl.New("html").Funcs(html_tmpl.FuncMap{
|
||||||
|
"strings_join": strings.Join,
|
||||||
|
}).ParseGlob(path.Join(templatePath, "*.html"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Critical("Error loading html templates: ", err)
|
log.Critical("Error loading html templates: ", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,17 +100,11 @@ function delBook(){
|
||||||
<form class="form-inline" method="POST" action="/list/">
|
<form class="form-inline" method="POST" action="/list/">
|
||||||
<input type="hidden" id="book_id" name="book_id" value="{{.Book.ID}}">
|
<input type="hidden" id="book_id" name="book_id" value="{{.Book.ID}}">
|
||||||
<div class="input-append">
|
<div class="input-append">
|
||||||
<input type="text" data-provide="typeahead" id="list" name="list">
|
<input type="text" data-provide="typeahead" data-source='["{{strings_join .UserLists "\", \""}}"]' data-items="4" id="list" name="list" autocomplete="off">
|
||||||
<button type="submit" class="btn btn-primary">Add to list</button>
|
<button type="submit" class="btn btn-primary">Add</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
|
||||||
$(window).load(function() {
|
|
||||||
$('.typeahead').typeahead(source={{.UserLists}})
|
|
||||||
})
|
|
||||||
</script>
|
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
{{template "footer.html"}}
|
{{template "footer.html"}}
|
||||||
|
|
Reference in a new issue