diff --git a/web/components/management/rounds-card.js b/web/components/management/rounds-card.js index 9bee0679da02a7eed793fb5996aae682dcd36d99..8c9862a34d517bb22289cc80c669fe6c6b5fc8b7 100644 --- a/web/components/management/rounds-card.js +++ b/web/components/management/rounds-card.js @@ -31,11 +31,6 @@ class Round { <p class="card-header-title"> Tours </p> - <button id="round-new" class="button is-success"> - <span class="icon is-small"> - <i class="fas fa-plus"></i> - </span> - </button> </header> <div class="card-content"> <div id="round-list" class="content">Liste des tours</div> @@ -48,9 +43,6 @@ class Round { handleDom() { let roundHandler = this; - document.getElementById(`round-new`).addEventListener("click", function () { - roundHandler.newRound(); - }); document .getElementById(`round-modal-close`) @@ -142,9 +134,17 @@ class Round { } async displayRounds() { + document.getElementById("round-list").innerHTML = /* HTML */ `<button + id="round-new" + class="button large-button is-success" + > + <span class="icon is-small"> + <i class="fas fa-plus"></i> + </span> + </button>`; let rounds = await this.RoundModel.getRounds(); const markup = rounds.map((round) => this.roundTemplate(round)).join(""); - document.getElementById("round-list").innerHTML = markup; + document.getElementById("round-list").innerHTML += markup; let roundHandler = this; rounds.map(async (round) => { @@ -171,6 +171,10 @@ class Round { roundHandler.activateRound(round); }); }); + + document.getElementById(`round-new`).addEventListener("click", () => { + this.newRound(); + }); } roundTemplate(round) {