rvera / image-picker

Image Picker is a simple jQuery plugin that transforms a select element into a more user friendly graphical interface.
http://rvera.github.com/image-picker
Other
907 stars 216 forks source link

How to import image-picker in js #133

Closed jaclyngu closed 5 years ago

jaclyngu commented 5 years ago

Thanks for this plugin. I am quite a rookie and I want to write $("#category_select").imagepicker({ show_label: true });

in my javascript file (it only contains this single line), but there is no "export" in your source code. So when I compile by Webpack, it keeps giving me the error test_picker.js:2 Uncaught TypeError: $(...).imagepicker is not a function at test_picker.js:2

What should I do?

darraghenright commented 5 years ago

I assume you installed the image-picker library with npm or yarn? If so, you should do the following:

import 'image-picker'

By the way - you might get a ReferenceError if you don't have jQuery publicly exposed (this is what brought me to this issue actually). In a pinch, the following should work:

global.$ = global.jQuery = require('jquery');
Humni commented 5 years ago

Closing as it looks like this has been resolved