🎨 Choosing a suggestion don't reload the page anymore

This commit is contained in:
Florian Sylvain
2021-10-31 12:43:08 +01:00
parent 69d9b45985
commit 76c6f9026c
2 changed files with 8 additions and 9 deletions
+7 -4
View File
@@ -68,12 +68,15 @@ function realTimeDisplay() {
.then(function(data) { .then(function(data) {
suggestions.innerHTML = "" suggestions.innerHTML = ""
data.forEach(elem => { data.forEach(elem => {
let outsideTag = document.createElement('a')
outsideTag.href = "index.php?author=" + elem
let name = document.createElement('p') let name = document.createElement('p')
name.innerHTML = elem name.innerHTML = elem
outsideTag.appendChild(name) name.addEventListener('click', () => {
suggestions.appendChild(outsideTag) document.querySelector('#results-count').innerHTML = ""
document.querySelector('#results').innerHTML = ""
searchBar.value = elem
requestToApi(elem)
})
suggestions.appendChild(name)
}) })
}) })
} }
+1 -5
View File
@@ -115,11 +115,7 @@ body {
padding: 10px; padding: 10px;
margin: 5px; margin: 5px;
border-radius: 10px; border-radius: 10px;
} cursor: pointer;
#suggestions a {
color: inherit;
text-decoration: none;
} }
#suggestions p:hover { #suggestions p:hover {