simonwep / pickr

🎨 Flat, simple, multi-themed, responsive and hackable Color-Picker library. No dependencies, no jQuery. Compatible with all CSS Frameworks e.g. Bootstrap, Materialize. Supports alpha channel, rgba, hsla, hsva and more!
https://simonwep.github.io/pickr
MIT License
4.29k stars 287 forks source link

Can't initialize Pickr at all #281

Closed iammati closed 3 years ago

iammati commented 3 years ago

Uncaught ReferenceError: Pickr is not defined - followed instructions but still not callable?

Your environment:

Version (see Pickr.version): 1.8.1
Used bundle (es5 or normal one): both
Used theme (default is classic):  nano
Browser-version:  Brave | 1.24.85 Chromium: 90.0.4430.212 (Official Build) (64-bit)
Operating-system:  Windows 10

I've tried adding both normal as the es5 pickr.min.js files but when calling Pickr.create or just Pickr inside the DevTools console it's keep throwing me this: Uncaught ReferenceError: Pickr is not defined. I took a look into the Network tab of DevTools, which shows me that pickr.min.js has been loaded fine with a HTTP status header 200 (which is fine). I've no idea what could cause this behaviour..?

iammati commented 3 years ago

Nevermind, since webpack is building by "moving" the variables inside a function scope it's obviously that e.g. Pickr or any other kind of (local) variable isn't accessible..

Primary the issue was caused by the fact that when passing the el-attribute (which represents a query / element) to pickr which doesn't exists throws a not really userfriendly error, maybe adding a condition that such an element / node doesn't exists with the passed query would be better (for future users?).

Thanks anyways for this open-source neat colorpicker, appreciate it @Simonwep ! :)