Ninja Ninja - 6 months ago 22
jQuery Question

setTimeout after .click

The dialog won't show up after I pressed button.

Any solutions?

setTimeout(function() {
$(".tile").click(function() {
$("#dialog").dialog(); ("Game Over" + score)
gameRunning = false;
$("#dialogbox").text("Your score:" + score)
}, 60000);

Answer

What your code does is binding event handle after 60 seconds. If you want to show the dialog after 60 second on click event then do it like this.

$(".tile").click(function() {
  setTimeout(function() {
    $("#dialog").dialog();
    ("Game Over" + score)
    gameRunning = false;
    $("#dialogbox").text("Your score:" + score)
  }, 60000);
});

If you want the same behavior in your question then you are missing closing brace and parenthesis of click handler.

setTimeout(function() {
  $(".tile").click(function() {
    $("#dialog").dialog();
    ("Game Over" + score)
    gameRunning = false;
    $("#dialogbox").text("Your score:" + score);
  })
//^---- missing closing
}, 60000);