It seems like most people adopt a workaround instead of fixing the problem but it may just be a rare problem that I am encountering every time. I am extending the transcodem(.com) scheduler to use jquery-fileupload-rails on top of carrierwave. I follow the steps stated in the README.md. These are the steps seen on railscasts.com/episodes/381 also. But when I call $(selector).fileupload() I get the error Object [object Object] has no method 'fileupload'. I get it on two fresh copies of the codem scheduler. The problem is the "/assets/jquery-fileupload/jquery.fileupload.js script can not run until /assets/jquery-fileupload/vendor/jquery.ui.widget.js is loaded and run. If you copy the code into console from both files you will see that it will give the error Object function ( selector, context ) { // The jQuery object is actually just the init constructor 'enhanced' return new jQuery.fn.init( selector, context, rootjQuery ); } has no method 'widget' if you do them out of order. This is what is happening in the case of the normal includes done by //= require jquery-fileupload/basic in application.js. To overcome this I have added these scripts manually and waited for one to load before adding the next. These should be implemented in a way that ensures the first is loaded before the second tries to run. If this does not happen on a clean install it may be my specific use case or something I am doing wrong. If anyone has this problem please comment. I would like to investigate this issue when I get some time.
UPDATE: I am new to rails but I think this problem would be solved if I was in production mode and the javascript files were combined into one large file then this would obviously execute in the correct order bypassing the issue. So is this a bug or just something to expect in development mode or anytime the scripts are not combined into application.js?
Just load the files in the correct order or use jquery-fileupload/basic. Sprockets does not do runtime dependency management, it just loads or concatenated the scripts in the order specified.
It seems like most people adopt a workaround instead of fixing the problem but it may just be a rare problem that I am encountering every time. I am extending the transcodem(.com) scheduler to use jquery-fileupload-rails on top of carrierwave. I follow the steps stated in the README.md. These are the steps seen on railscasts.com/episodes/381 also. But when I call
$(selector).fileupload()
I get the errorObject [object Object] has no method 'fileupload'
. I get it on two fresh copies of the codem scheduler. The problem is the"/assets/jquery-fileupload/jquery.fileupload.js
script can not run until/assets/jquery-fileupload/vendor/jquery.ui.widget.js
is loaded and run. If you copy the code into console from both files you will see that it will give the errorObject function ( selector, context ) { // The jQuery object is actually just the init constructor 'enhanced' return new jQuery.fn.init( selector, context, rootjQuery ); } has no method 'widget'
if you do them out of order. This is what is happening in the case of the normal includes done by//= require jquery-fileupload/basic
in application.js. To overcome this I have added these scripts manually and waited for one to load before adding the next. These should be implemented in a way that ensures the first is loaded before the second tries to run. If this does not happen on a clean install it may be my specific use case or something I am doing wrong. If anyone has this problem please comment. I would like to investigate this issue when I get some time.UPDATE: I am new to rails but I think this problem would be solved if I was in production mode and the javascript files were combined into one large file then this would obviously execute in the correct order bypassing the issue. So is this a bug or just something to expect in development mode or anytime the scripts are not combined into application.js?