ga-wdi-boston / game-project

Other
7 stars 102 forks source link

error message #118

Closed pvdri closed 8 years ago

pvdri commented 8 years ago

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

RDegnen commented 8 years ago

What are you doing to get this error?

pvdri commented 8 years ago

If I knew that I would have fixed it...

RDegnen commented 8 years ago

Are you clicking a button? Making an AJAX request?? It isn't enough information to say your just getting an error.

pvdri commented 8 years ago

I'm filling out my fields and click submit...

RDegnen commented 8 years ago

https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=Uncaught+TypeError:+Cannot+read+property+%27replace%27+of+null(anonymous+function)+jquery

Your DOM might not be rendered before jQuery starts trying to interact with elements on the page

pvdri commented 8 years ago

so what you recommend as a remedy?

RDegnen commented 8 years ago

Make sure all your code is running only after the DOM has been rendered.

pvdri commented 8 years ago

how does one make sure that the dom has rendered?

pvdri commented 8 years ago

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

RealWeeks commented 8 years ago

Can you post your document ready function?

pvdri commented 8 years ago
$(document).ready(function () {
    newGame();
    turn = 1;
    if (turn === 0){
      $("#notice").text(ogo);
    }
    else {
      $("#notice").text(xgo);
    }
});
RealWeeks commented 8 years ago

What is the newGame function?

pvdri commented 8 years ago
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);}
          }
    });
};
laurenfazah commented 8 years ago

@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.

pvdri commented 8 years ago

thank you lauren, ross helped, i think we're good....

laurenfazah commented 8 years ago

@pvdri please close this and all other residual open issues.

RDegnen commented 8 years ago

Please close