caustique / chessboard-js

A responsive mobile-first javascript chessboard library.
http://caustique.github.io/chessboard-js
MIT License
33 stars 11 forks source link

Uncaught TypeError: Cannot read property 'id' of undefined #4

Open prologic opened 7 years ago

prologic commented 7 years ago

Trying to do some pretty simple stuff here and following code snippets from the examples and running into an exception I don't understand:

Uncaught TypeError: Cannot read property 'id' of undefined
    at HTMLDivElement.onSquareClicked (chessboard.js:694)
    at HTMLDivElement.dispatch (jquery.min.js:3)
    at HTMLDivElement.q.handle (jquery.min.js:3)

Looking at L694 its not really clear to me what $(this).context is suppose to be referencing here?

alexvilanovab commented 7 years ago

Hi! I'm also dealing with that problem. Could you solve it?

sudeshchouhan commented 5 years ago

@prologic @alexvilanovab Hi, I have found solution for the problem. In the file "chessboard.js", go to line number 694, it is trying to get the id of the clicked piece. It is using "context" but context is depreciated in JQuery version 3.0 and onward. See https://api.jquery.com/context/ So now it's not able to get id if the clicked piece.

Solution is that simply replace $(this).context.id with this.id or $(this).attr("id")

Even below mentioned project is using this library and they have also mentioned there that "The chess pieces are not moving on touch devices (tablets and smartphones)." https://github.com/LabinatorSolutions/BoldChess-Stockfish-Web-GUI

I am new to GitHub. Please someone update the chessboard.js and chessboard.min.js as i suggested.