From 3a5f485c42ff88ba63ea08addf5e347fe03e9e43 Mon Sep 17 00:00:00 2001 From: Makaci Michael Gabriel Date: Fri, 12 Jan 2024 10:22:42 +0100 Subject: [PATCH] =?UTF-8?q?Correction=20pour=20r=C3=A9cuperer=20les=20attr?= =?UTF-8?q?ibutes=20du=20bouton=20faction=20et=20affichage=20information?= =?UTF-8?q?=20faction=20sur=20la=20modal?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- html/templates/factions/faction_modal.html | 2 ++ js/controllers/faction.js | 16 +++++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/html/templates/factions/faction_modal.html b/html/templates/factions/faction_modal.html index 7eec8fc..c1d975a 100644 --- a/html/templates/factions/faction_modal.html +++ b/html/templates/factions/faction_modal.html @@ -2,6 +2,8 @@
+

+

diff --git a/js/controllers/faction.js b/js/controllers/faction.js index 4d5c78e..961f46c 100644 --- a/js/controllers/faction.js +++ b/js/controllers/faction.js @@ -16,16 +16,18 @@ export default (temp_engine) => { Faction.list_all((factions) => { add_factions(factions); - temp_engine.add_event("#btn-faction", "click", (button) => { - const attributes = button.target.attributes; - const faction_symbol = attributes["data-symbol"].value; + temp_engine.add_event("#btn-faction", "click", (e) => { + console.log(button); + const faction_symbol = $(e.target).attr("data-symbol"); const faction = factions.find((element) => { - element.symbol == faction_symbol; + return element.symbol == faction_symbol; }); - console.log(faction); - - $("#faction-title").html(""); + $("#faction-title").html(faction.symbol); + $("#faction-description").html(`Description: ${faction.description}`); + $("#faction-headquarters").html( + `Headquarters: ${faction.headquarters}` + ); modal.show(); });