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"
|
||||
"net/http"
|
||||
"path"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"gitlab.com/trantor/trantor/lib/database"
|
||||
|
@ -57,7 +58,9 @@ func InitTemplate(assetsPath string) *Template {
|
|||
var t Template
|
||||
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 {
|
||||
log.Critical("Error loading html templates: ", err)
|
||||
}
|
||||
|
|
|
@ -100,17 +100,11 @@ function delBook(){
|
|||
<form class="form-inline" method="POST" action="/list/">
|
||||
<input type="hidden" id="book_id" name="book_id" value="{{.Book.ID}}">
|
||||
<div class="input-append">
|
||||
<input type="text" data-provide="typeahead" id="list" name="list">
|
||||
<button type="submit" class="btn btn-primary">Add to list</button>
|
||||
<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</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$(window).load(function() {
|
||||
$('.typeahead').typeahead(source={{.UserLists}})
|
||||
})
|
||||
</script>
|
||||
{{end}}
|
||||
|
||||
{{template "footer.html"}}
|
||||
|
|
Reference in a new issue