I am using Rails 6, and I need to use jquery file upload plugin, I would like to add manually instead of using yarn, so I downloaded this file here: https://cdnjs.cloudflare.com/ajax/libs/blueimp-file-upload/9.31.0/js/jquery.fileupload.js and put it into app/javascript
folder
then in app/javascript/packs/application.js
I added the line
require("jquery.fileupload")
In my app/javascript/main.js
:
$('#file-input').fileupload()
I get the error :
TypeError: $(...).fileupload is not a function
If I put $('#file-input').fileupload()
in javascript/packs/application.js
like this :
require("jquery.fileupload")
$('#file-input').fileupload()
The error disappear ! so the issue seems to be that the plugin can only be accessed in application.js and not in other files, how I can solve that ?
I lost 2 or 3 hours trying use webpack without success.
Then simple download *.js
files directly from blueimp repository to app/javascript/packs/vendor
and import it in application.js
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.