Closed pvdri closed 8 years ago
What are you doing to get this error?
If I knew that I would have fixed it...
Are you clicking a button? Making an AJAX request?? It isn't enough information to say your just getting an error.
I'm filling out my fields and click submit...
Your DOM might not be rendered before jQuery starts trying to interact with elements on the page
so what you recommend as a remedy?
Make sure all your code is running only after the DOM has been rendered.
how does one make sure that the dom has rendered?
Also, it doesn't sound like that the case because I use jquery to set elements of the dom in the tic tac toe game
Can you post your document ready function?
$(document).ready(function () {
newGame();
turn = 1;
if (turn === 0){
$("#notice").text(ogo);
}
else {
$("#notice").text(xgo);
}
});
What is the newGame function?
let newGame = function () {
$('td').one('click', function () {
if (turn === 0) {
turn = 1;
$(this).text(oplayer);
let x = $(this).attr("id");
switch (x) {
case $("#a1").attr("id"):
arb[0] = 0;
break;
case $("#a2").attr("id"):
arb[1] = 0;
break;
case $("#a3").attr("id"):
arb[2] = 0;
break;
case $("#b1").attr("id"):
arb[3] = 0;
break;
case $("#b2").attr("id"):
arb[4] = 0;
break;
case $("#b3").attr("id"):
arb[5] = 0;
break;
case $("#c1").attr("id"):
arb[6] = 0;
break;
case $("#c2").attr("id"):
arb[7] = 0;
break;
case $("#c3").attr("id"):
arb[8] = 0;
break;
}
winner();
if($("#notice2").text() === owins)
{disallow();}
else if (isFull() !== false)
{$("#notice").text(nowins);}
else {$("#notice").text(xgo);}
}
else {
turn = 0;
$(this).text(xplayer);
let y = $(this).attr("id");
switch (y) {
case $("#a1").attr("id"):
arb[0] = 1;
break;
case $("#a2").attr("id"):
arb[1] = 1;
break;
case $("#a3").attr("id"):
arb[2] = 1;
break;
case $("#b1").attr("id"):
arb[3] = 1;
break;
case $("#b2").attr("id"):
arb[4] = 1;
break;
case $("#b3").attr("id"):
arb[5] = 1;
break;
case $("#c1").attr("id"):
arb[6] = 1;
break;
case $("#c2").attr("id"):
arb[7] = 1;
break;
case $("#c3").attr("id"):
arb[8] = 1;
break;
}
winner();
if($("#notice2").text() === xwins)
{disallow();}
else if (isFull() !== false)
{$("#notice").text(nowins);}
else
{$("#notice").text(ogo);}
}
});
};
@pvdri it looks like you're assigned to @RDegnen with another issue, but when he's done, I'd love for you to walk me through this newGame()
function you have.
thank you lauren, ross helped, i think we're good....
@pvdri please close this and all other residual open issues.
Please close
still getting error message
client?cd17:5Uncaught TypeError: Cannot read property 'replace' of null(anonymous function) @ client?cd17:5(anonymous function) @ client?cd17:96webpack_require @ bootstrap 33da82d…:50(anonymous function) @ bootstrap 33da82d…:93webpack_require @ bootstrap 33da82d…:50(anonymous function) @ bootstrap 33da82d…:93(anonymous function) @ bootstrap 33da82d…:93