feat: Basic Query + Autocomplete

This commit is contained in:
Hussain Nagaria
2021-04-22 14:21:29 +05:30
committed by marination
parent 0c47f3a876
commit e82833f14a
4 changed files with 55 additions and 11 deletions

View File

@@ -0,0 +1,5 @@
.item-thumb {
height: 50px;
width: 50px;
object-fit: cover;
}

View File

@@ -1,7 +1,11 @@
{% extends "templates/web.html" %}
{% block title %}{{ _('Search') }}{% endblock %}
{%- block head_include %}
<link rel="stylesheet" href="search.css">
{% endblock -%}
{% block header %}
<div class="mb-6">{{ _('Search Products') }}</div>
{% endblock header %}

View File

@@ -1,12 +1,16 @@
console.log("search.js loaded");
console.log("search.js reloaded");
const search_box = document.getElementById("search-box");
const results = document.getElementById("results");
function populateResults(data) {
console.log(data);
html = ""
for (let res of data.message) {
html += `<li>${res}</li>`
html += `<li>
<img class="item-thumb" src="${res.thumbnail || ''}" />
<a href="/${res.route}">${res.web_item_name}</a>
</li>`
}
console.log(html);
results.innerHTML = html;