chessboardjs
chessboardjs copied to clipboard
Option to pass jQuery instance
Hello,
In my project, I don't have $ exposed as a global variable.
Is there any possibility to pass jQuery instance to chessboard.js? Or is there any plan to do this?
Thanks
There isn't any need to pass the jQuery object, if you look at the source code:
var $ = window['jQuery']
https://github.com/oakmac/chessboardjs/blob/master/src/chessboard.js#L12
This variable assignment is within a closure (an Immediately Invoked Function Expression to be precise) so the $ is only exposed inside the library, thus, you don't need the $ exposed globally, you do however need jQuery on the window object (!) as this is a hard dependency of the library!
Hope that helps.
This is precisely my issue.
I don't have jQuery on the window object.
But I can get a reference to the jQuery object and then pass it along the chessboard.js to satisfy the hard dependency without attaching jQuery to window.
Hope that makes sense.