{"action":"created","issue":{"url":"https://api.github.com/repos/ga-wdi-boston/game-project/issues/486","repository_url":"https://api.github.com/repos/ga-wdi-boston/game-project","labels_url":"https://api.github.com/repos/ga-wdi-boston/game-project/issues/486/labels{/name}","comments_url":"https://api.github.com/repos/ga-wdi-boston/game-project/issues/486/comments","events_url":"https://api.github.com/repos/ga-wdi-boston/game-project/issues/486/events","html_url":"https://github.com/ga-wdi-boston/game-project/issues/486","id":206537260,"number":486,"title":"Click Handlers After a Win","user":{"login":"ladypineapple","id":24965469,"avatar_url":"https://avatars.githubusercontent.com/u/24965469?v=3","gravatar_id":"","url":"https://api.github.com/users/ladypineapple","html_url":"https://github.com/ladypineapple","followers_url":"https://api.github.com/users/ladypineapple/followers","following_url":"https://api.github.com/users/ladypineapple/following{/other_user}","gists_url":"https://api.github.com/users/ladypineapple/gists{/gist_id}","starred_url":"https://api.github.com/users/ladypineapple/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ladypineapple/subscriptions","organizations_url":"https://api.github.com/users/ladypineapple/orgs","repos_url":"https://api.github.com/users/ladypineapple/repos","events_url":"https://api.github.com/users/ladypineapple/events{/privacy}","received_events_url":"https://api.github.com/users/ladypineapple/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2017-02-09T15:30:19Z","updated_at":"2017-02-12T19:06:53Z","closed_at":"2017-02-12T19:06:53Z","body":"I'm having issues getting my reset button to turn clicking back on after a win. (There's no off click for a draw so the issue doesn't occur unless the reset is after a win.)\r\n\r\nIf a player wins clicking is disabled, but when the reset button is pressed clicking does not turn back on. I have tried adding it to the function that is called by the reset button, to the click handler for the reset button, and to the function that sets the player's turn. Nothing would work. \r\n\r\nThis is how I turned it off:\r\n```\r\n      if (isWinner(gameBoard) === true) {\r\n        $('.player-turn').text('');\r\n        $('.message-player').text('You Win');\r\n        $('.game-box').off('click');\r\n```\r\nI've tried adding it to the current player's turn \r\n```\r\n  currentPlayTurn = messageText(currentPlayer);\r\n  $('.player-turn').text(currentPlayTurn);\r\n  $('.message-player').text('');\r\n  $('.game-box').text('');\r\n  $('.game-box').on('click');\r\n};\r\n```\r\nTo the reset function: \r\n```\r\nconst clearBoard = function () {\r\n  gameBoard = ['', '', '', '', '', '', '', '', ''];\r\n  currentPlayer = playerX;\r\n  playSymbol = '';\r\n  currentPlayTurn = '';\r\n $('.game-box').on('click');\r\n```\r\nAnd to the button itself:\r\n```\r\n$('#reset-button').on('click', function () {\r\n  console.log('reset completed');\r\n  clearBoard();\r\n $('.game-box').on('click');\r\n});\r\n```\r\n\r\nI think this is an issue with bubbling but I can't figure out how to stop it.\r\n\r\nThanks,\r\nMaura"},"comment":{"url":"https://api.github.com/repos/ga-wdi-boston/game-project/issues/comments/279240265","html_url":"https://github.com/ga-wdi-boston/game-project/issues/486#issuecomment-279240265","issue_url":"https://api.github.com/repos/ga-wdi-boston/game-project/issues/486","id":279240265,"user":{"login":"ladypineapple","id":24965469,"avatar_url":"https://avatars.githubusercontent.com/u/24965469?v=3","gravatar_id":"","url":"https://api.github.com/users/ladypineapple","html_url":"https://github.com/ladypineapple","followers_url":"https://api.github.com/users/ladypineapple/followers","following_url":"https://api.github.com/users/ladypineapple/following{/other_user}","gists_url":"https://api.github.com/users/ladypineapple/gists{/gist_id}","starred_url":"https://api.github.com/users/ladypineapple/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ladypineapple/subscriptions","organizations_url":"https://api.github.com/users/ladypineapple/orgs","repos_url":"https://api.github.com/users/ladypineapple/repos","events_url":"https://api.github.com/users/ladypineapple/events{/privacy}","received_events_url":"https://api.github.com/users/ladypineapple/received_events","type":"User","site_admin":false},"created_at":"2017-02-12T19:06:53Z","updated_at":"2017-02-12T19:06:53Z","body":"This was resolved by changing the reset button to a start game button that sets the on.click and runs the game over function to set the off.click on a win or draw\r\n\r\n```\r\nfunction clearBoard(event) {\r\n  // gameBoard[i] = '';\r\n  let gameEvent = event;\r\n  playerX = 1;\r\n  playerO = 2;\r\n  gameBoard = ['', '', '', '', '', '', '', '', ''];\r\n  currentPlayer = '';\r\n  playSymbol = 'x';\r\n  currentPlayTurn = '';\r\n  over = false;\r\n\r\n  console.log(gameEvent);\r\n  $('.game-board-container div').on('click', function () {\r\n    const messageText = function (currentPlayer) {\r\n      return 'It\\'s your turn, Player ' + currentPlayer;\r\n    };\r\n\r\n    let divClass = $(this).attr('class');\r\n    let divClassNum = parseInt(divClass);\r\n    console.log(divClassNum);\r\n    if (isSpaceEmpty(divClassNum) === true) {\r\n\r\n      $('.message-player').text('');\r\n      symbolValue(currentPlayer, divClassNum);\r\n      $(this).text(playSymbol);\r\n      if (gameOver(gameBoard) === true) {\r\n        $('.player-turn').text('');\r\n        $('.message-player').text('Game Over');\r\n        over = true;\r\n      } else {\r\n```\r\nThe gameOver function is:\r\n```\r\nconst gameOver = function (arr) {\r\n  let isBF = isBoardFilled(arr);\r\n  let isW = isWinner(arr);\r\n  if (isBF || isW) {\r\n    $('.game-box').off('click');\r\n    return true;\r\n  }\r\n};\r\n```"}}
{"actor":{"display_login":"ladypineapple"}}