diff --git a/js/src/board.ext.js b/js/src/board.ext.js index 9413078..3d329e4 100644 --- a/js/src/board.ext.js +++ b/js/src/board.ext.js @@ -4,8 +4,7 @@ const loadBoard = (board) => { const boardId = board.getAttribute("data-board"); const getSquare = square => board.getElementsByClassName(square)[0]; const moveSelected = event => { - const move = event.target.getAttribute("data-move"); - console.log(move); + const move = event.currentTarget.getAttribute("data-move"); board.setAttribute("data-hx-vals", JSON.stringify({"move": move})); htmx.trigger(document.body, "chess-move-" + boardId, {}); }; @@ -49,7 +48,6 @@ const loadBoard = (board) => { htmx.defineExtension('board', { onEvent : function(name, event) { - console.log(name); if (name !== "htmx:afterProcessNode" || ( event?.target?.getAttribute("hx-ext") ?? diff --git a/src/View/fragments/board.php b/src/View/fragments/board.php index 0d945f0..c7c4d9e 100644 --- a/src/View/fragments/board.php +++ b/src/View/fragments/board.php @@ -29,14 +29,14 @@ function getImageForPice(Piece $piece): string { } ?> -
- Current Player: getCurrentSide()->name ?>
- Game State: getGameState()->name ?> -
" id="board" data-board="" - data-hx-ext="board" data-hx-post="/?move" data-hx-trigger="chess-move- from:body" + data-hx-ext="board" + data-hx-post="/?move" + data-hx-trigger="chess-move- from:body" + data-hx-swap="outerHTML" + data-hx-target="this" > getMovesForPiece($piece) : []; $hasMoves = count($moves) > 0; ?> -
"> +
" + data-square="" + >