0

Hi this app is working but have few problems,example my (#join-game) button is didnt work after the append.You can check my files down,thanks for help.


MY JAVASCRIPT / JQUERY FILE (I think problem is not here.)

  let gid = $(this).attr("class");
  $.ajax({
    url: "/join",
    method: "POST",
    data: { gameid: gid },
  }).done(function (response) {
    if (response === "Waiting for players...") {
      return;
    } else {
      let lobbystatus = $(".lobby-status");
      var count = 3;
      let interval = setInterval(() => {
        if (count === -1) {
          clearInterval(interval);
          startgame(response);
        } else {
          lobbystatus.text("Starts in " + count + " seconds...");
          count--;
        }
      }, 1000);
    }
  });
});```

My script session.(check image).


(I think problem is javascript file or script tag because when i login to site firstly my javascript file is loading,cards is append after the javascript load but I tried reload javascript file and it didnt work too.[enter image description here][1])


  [1]: https://i.stack.imgur.com/MI3cg.png
  • You haven't shown any of the code relevant to the problem in the question, however from your description of the issue, where a dynamically created element doesn't respond to an event handler, I'm going to assume you need to change the logic to use delegated event handlers. – Rory McCrossan May 03 '22 at 14:55

0 Answers0