Commit 0c2e35bb authored by Las Zenow's avatar Las Zenow

Fix the typeahead

parent a40b5ac5
......@@ -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"}}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment