在rails中,当在清单文件之间切换时,javascript文件加载方式不同

时间:2017-03-22 18:04:00

标签: ruby-on-rails ruby-on-rails-4 asset-pipeline rails-assets

我正在使用Rails和Bootstrap。当你在浏览器中访问它时,我有一个完美的页面。当我在我的网站上转到另一个页面,然后单击一个链接,将我带回页面时,javascript文件以完全不同的顺序加载。这对我来说没有意义,因为我按照我的logged_out.js清单文件中描述的显式顺序加载js文件:

// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require jquery_ujs
//= require ./logged_out/theme_vendor/bootstrap.min
//= require ./logged_out/theme_vendor/smoothscroll.min
//= require ./logged_out/theme_vendor/jquery.backstretch.min
//= require ./logged_out/theme_vendor/jquery.countTo
//= require ./logged_out/theme_vendor/contact
//= require ./logged_out/theme_vendor/jquery.waypoints.min
//= require ./logged_out/theme_custom/theme

在浏览器页面中,它显示当我通过转到URL加载页面时,文件按上面的顺序加载。当我通过链接进入页面时,文件的顺序是随机的。如何解决此问题,以便文件始终按此顺序加载?

另外需要注意的是:我有两个清单文件:logged_out.js和logged_in.js。似乎订单不匹配只发生在我从带有logged_in.js的页面到logged_out.js时。我需要两种类型的清单文件,因此删除一个或移动到一个清单文件不是一个选项。

0 个答案:

没有答案