chessboardjs icon indicating copy to clipboard operation
chessboardjs copied to clipboard

Option to pass jQuery instance

Open mindtricksdev opened this issue 8 years ago • 2 comments

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

mindtricksdev avatar Aug 15 '17 22:08 mindtricksdev

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.

Webby2013 avatar Sep 04 '17 21:09 Webby2013

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.

mindtricksdev avatar Sep 04 '17 23:09 mindtricksdev