2021-04-22 08:51:29 +00:00
|
|
|
console.log("search.js reloaded");
|
2021-04-21 08:22:23 +00:00
|
|
|
|
|
|
|
const search_box = document.getElementById("search-box");
|
|
|
|
const results = document.getElementById("results");
|
|
|
|
|
|
|
|
function populateResults(data) {
|
2021-04-22 08:51:29 +00:00
|
|
|
console.log(data);
|
2021-04-21 08:22:23 +00:00
|
|
|
html = ""
|
|
|
|
for (let res of data.message) {
|
2021-04-22 08:51:29 +00:00
|
|
|
html += `<li>
|
|
|
|
<img class="item-thumb" src="${res.thumbnail || ''}" />
|
|
|
|
<a href="/${res.route}">${res.web_item_name}</a>
|
|
|
|
</li>`
|
2021-04-21 08:22:23 +00:00
|
|
|
}
|
|
|
|
console.log(html);
|
|
|
|
results.innerHTML = html;
|
|
|
|
}
|
|
|
|
|
|
|
|
search_box.addEventListener("input", (e) => {
|
|
|
|
frappe.call({
|
|
|
|
method: "erpnext.templates.pages.product_search.search",
|
|
|
|
args: {
|
|
|
|
query: e.target.value
|
|
|
|
},
|
|
|
|
callback: (data) => {
|
|
|
|
populateResults(data);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
});
|