tors / jquery-fileupload-rails

jQuery File Upload integrated for Rails
669 stars 253 forks source link

fileupload() is not function #101

Open raoaamirmuhammad opened 4 years ago

raoaamirmuhammad commented 4 years ago

I have the following jquery gems in my Gemfile gem 'jquery-rails' gem "jquery-ui-rails" gem 'jquery-fileupload-rails'

I added in my application.js //= require jquery-fileupload/basic

Form is <%= form_with model: @xyz, html: { multipart: true, id: "fileupload" } do |f| %> <% end %>

and the script is <script> $(function() { $('#fileupload').fileupload(); }); </script>

I got error Screenshot from 2019-09-17 10-21-34

I am using activestorage, not carrierwave Can anyone help me here

felixbuenemann commented 4 years ago

Have you also required jquery above jquery-fileupload in application.js?

raoaamirmuhammad commented 4 years ago

Yes I required the following jquery before jquery-fileupload //= require jquery3 //= require jquery-ui

raoaamirmuhammad commented 4 years ago

I also required jquery-fileupload but didn't work

felixbuenemann commented 4 years ago

The error message shows jquery-1.12.4.js, but you said you require jquery3 which is jQuery 4.3.1 in the latest version of jquery-rails, so I think you are loading another copy of jQuery with some other vendored script and that is causing the problem.

Check your assets in chrome devtools, to see were the duplicate jQuery is comming from and get rid of it.