3

这可能是将具有依赖关系的外部脚本引入 Rails 的简单案例。

我试图让我的 Adob​​e Edge 生成的动画在我的 Rails 应用程序中工作,第一步是包含所有 Adob​​e Edge 生成的 js 文件,但到目前为止,我只是得到一堆404 Not Found Errors我已包含在文件中的 EdgeApplication.js文件。

这是我的 Application.js 文件

//= require jquery
//= require jquery_ujs
//= require underscore
//= require backbone
//= require california_internet
//= require hero_edgePreload
//= require edge_includes/edge.1.5.0.min
//= require hero_edge
//= require hero_edgeActions

以下是 Edge 的 Preloader.js 如何尝试查找某些文件...

aLoader=[{load:"edge_includes/jquery-1.7.1.min.js"},{load:"edge_includes/edge.1.5.0.min.js"},{load:"hero_edge.js"},{load:"hero_edgeActions.js"}]
4

2 回答 2

1

Michael Johnston 更改 Edge 的 aLoader 路径的解决方案有效,但会出错。在本地主机上时,我会Uncaught HierarchyRequestError: A Node was inserted somewhere it doesn't belong.随机获取,而在每次页面刷新时部署到 Heroku 之后。

此外,我的应用程序已经在更高版本中依赖 jQuery - 因此从 Edge 动画添加一个可能会导致冲突。

经过反复试验,我决定使用此解决方案:

  1. 将整个动画放入/public/edge文件夹
  2. 将动画放入 iframe:<iframe class="animation-container" src='/edge/animation.html' />

不是最优雅的,但肯定会省去很多麻烦。

于 2013-11-27T09:30:25.550 回答
1

我得到这个工作的方式是hero_edgePreload.js改变hero_edgePreload.js.erb

并改变:

aLoader=[
  {load:"edge_includes/jquery-1.7.1.min.js"},
  {load:"edge_includes/edge.1.5.0.min.js"},
  {load:"hero_edge.js"},
  {load:"hero_edgeActions.js"}
];

至:

aLoader=[
  // {load:"edge_includes/jquery-1.7.1.min.js"}, Already required in application.js
  {load:'<%= asset_path("edge.1.5.0.min.js") %>'},
  {load:'<%= asset_path("hero_edge.js") %>'},
  {load:'<%= asset_path("hero_edgeActions.js") %>'}
];

您也可以从您的需求中删除任何 Adob​​e Edge JS 文件application.js

您必须添加asset_path到其中的任何图像hero_edge.js并将其更改为hero_edge.js.erb

如果有更简单的方法,我很想知道:)

于 2013-10-28T08:12:28.823 回答