admin管理员组文章数量:1335824
I am using a Rails 4 application. I installed some JavaScript plugin files in "vendor/assets/javascripts", and some in "app/assets/javascripts" where I have some files that are invoking methods from the vendor files.
No methods from these are recognized and it seems that "app/assets/javascripts" files are loaded before "vendor/assets/javascripts" files. How can I deal with that?
For information my "application.js" calls:
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require rails.validations
//= require_tree .
and I am using gem 'jquery-rails'
.
I am using a Rails 4 application. I installed some JavaScript plugin files in "vendor/assets/javascripts", and some in "app/assets/javascripts" where I have some files that are invoking methods from the vendor files.
No methods from these are recognized and it seems that "app/assets/javascripts" files are loaded before "vendor/assets/javascripts" files. How can I deal with that?
For information my "application.js" calls:
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require rails.validations
//= require_tree .
and I am using gem 'jquery-rails'
.
2 Answers
Reset to default 5Any files in your vendor tree that you need must be required explicitly in your "application.js". It will pull in all the JavaScript in your "app/assets/" tree using the "require_tree".
You probably need to update your file to look something more like this:
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require rails.validations
//= require that_file_from_vendor_assets
//= require that_other_file_from_vendor_assets
//= require_tree .
where that_file_from_vendor_assets
is the vendor JavaScript that you need to be loaded up before it gets to your "app/assets/javascript" files.
Just change
//=require_tree .
like this:
//= require_self
Then files will be imported in the order of you put them to your application.js
file.
And don't forget <%= javascript_include_tag "application"%>
in your layout file.
本文标签: ruby on railsloading order JavaScript files in asset pipelineStack Overflow
版权声明:本文标题:ruby on rails - loading order JavaScript files in asset pipeline - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742399505a2467600.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论