From 76c6f9026c255d8030a288ed47450e17eedb2f81 Mon Sep 17 00:00:00 2001 From: Florian Sylvain Date: Sun, 31 Oct 2021 12:43:08 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Choosing=20a=20suggestion=20don'?= =?UTF-8?q?t=20reload=20the=20page=20anymore?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ProjetProgWeb/app.js | 11 +++++++---- ProjetProgWeb/stylesheet.css | 6 +----- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/ProjetProgWeb/app.js b/ProjetProgWeb/app.js index 076a02c..9a9a5d1 100644 --- a/ProjetProgWeb/app.js +++ b/ProjetProgWeb/app.js @@ -68,12 +68,15 @@ function realTimeDisplay() { .then(function(data) { suggestions.innerHTML = "" data.forEach(elem => { - let outsideTag = document.createElement('a') - outsideTag.href = "index.php?author=" + elem let name = document.createElement('p') name.innerHTML = elem - outsideTag.appendChild(name) - suggestions.appendChild(outsideTag) + name.addEventListener('click', () => { + document.querySelector('#results-count').innerHTML = "" + document.querySelector('#results').innerHTML = "" + searchBar.value = elem + requestToApi(elem) + }) + suggestions.appendChild(name) }) }) } diff --git a/ProjetProgWeb/stylesheet.css b/ProjetProgWeb/stylesheet.css index 0caf8c4..a3619ce 100644 --- a/ProjetProgWeb/stylesheet.css +++ b/ProjetProgWeb/stylesheet.css @@ -115,11 +115,7 @@ body { padding: 10px; margin: 5px; border-radius: 10px; -} - -#suggestions a { - color: inherit; - text-decoration: none; + cursor: pointer; } #suggestions p:hover {